Search code examples
react-nativepush-notificationexpo

React Native Expo Push Notification ExpoPushTokenManager.getDevicePushTokenAsync has been rejected


I'm using expo push notifications and on login I am setting the expo push token and saving it in the backend. However it is returning this error, couldnt find out how to solve it. Works fine when using Expo GO, when switched to EAS build it is returning this error:

Possible unhandled promise rejection Error: Call to function 'ExpoPushTokenManager.getDevicePushTokenAsync' has been rejected.
Caused by: java.lang.IllegalStateException:
Default FirebaseApp is not initialized in this process com.project.app. Make sure to call FirebaseApp.initializeApp(Context) first.

I have used the code provided in their documentation.


Solution

  • I experienced the same issue when I migrated to SDK 50. In June, Google will discontinue the old FCM legacy API, urging developers to switch to the newer FCM HTTP v1 API. Expo now supports the new v1 API (blog post), but since the credentials differ between the two versions, Expo requires you to upload new credentials to transition your projects from the old to the new API.

    When I updated to FCM V1, added the Google service account key, and rebuilt my app, push notifications worked again. Here are the steps on how to do that: https://docs.expo.dev/push-notifications/fcm-credentials/