I am using expo push-notification library to generate device push token and using it to send the notifications to the devices. It is working fine in expo managed workflow but when i am using the function
token = await Notifications.getExpoPushTokenAsync({});
i am getting an error which says :-
[Error: Call to function ‘ExpoPushTokenManager.getDevicePushTokenAsync’ has been rejected.
→ Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.notifications. Make sure to call FirebaseApp.initializeApp(Context) first.]
Can anyone please tell how to solve this error? I have tried everything but nothing seems to work.
I have tried to initialize the firebase app using the docs but it did not work as expected and it was giving the same error.
2
Answers
You need to pass the projectId in the object. You can find your projectId in app.json.
docs: https://docs.expo.dev/push-notifications/push-notifications-setup/
The error says it all, you missing firebase app initialization :
in the root of your app:
also make sure to correctly get your token: