Skip to content

Commit 3a8fb5a

Browse files
Moved firebase initialization into useNotifications hook.
1 parent efd0fc2 commit 3a8fb5a

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

hooks/usePushNotifications.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
handleForegroundNotification,
44
handleBackgroundNotifications,
55
registerForPushNotificationsAsync,
6-
} from "../utils/notifications.new";
7-
import messaging from "@react-native-firebase/messaging";
6+
} from "../utils/notifications";
7+
//import messaging from "@react-native-firebase/messaging";
88
import * as Notifications from "expo-notifications";
99
import { router } from "expo-router";
1010
import { getFirebaseApp } from "@/utils/firebase";
@@ -15,18 +15,15 @@ export const usePushNotifications = () => {
1515

1616
useEffect(() => {
1717
const initializeNotifications = async () => {
18-
// Initialize Firebase app
19-
try {
20-
getFirebaseApp();
21-
console.log("Firebase initialized in RootLayout");
22-
} catch (error) {
23-
console.error("Firebase initialization error:", error);
24-
}
18+
getFirebaseApp();
2519

2620
// Register for push notifications and get the push token
2721
registerForPushNotificationsAsync().then(async (token) => {
2822
if (token) {
29-
console.log("FCM Token:", token);
23+
console.log(
24+
"Finished registerping for Notifications - FCM Token:",
25+
token
26+
);
3027
setFcmToken(token); // Store the push token
3128
globalFcmToken = token; // Update the global token
3229
}

0 commit comments

Comments
 (0)