Search code examples
androidfirebasereact-nativeexpoexpo-notifications

Expo Push Notifications on Android


I have Expo Push Notifications working in the Expo Go app as well as iOS builds. However, it does not work on Android and I get this message when running getExpoPushTokenAsync():

Error: Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Please set your project ID. A valid Firebase project ID is required to communicate with Firebase server APIs: It identifies your project with Google.

I have followed all the steps listed in the documentation: my google-services.json is referenced in app.json and I double checked all the information there, including the project ID.

I tried to get the native device token via getDevicePushTokenAsync() and it worked, however even if I want to use the firebase notifications without Expo I get the same error further down when trying to set a firebase notification listener.

The problem may be linked with the fact that a firebase app is already running with the JS SDK (for realtimeDB and stoage) using other configs when I call getExpoPushTokenAsync(), I could maybe initialize a secondary Firebase App with the google-services.json config (which works, I tried it) but I do not see any way to force Expo Notifications to use this app.

Any idea of what is going on? Thanks!


Solution

  • So I fixed the issue if anyone still needs an answer:

    I was updating my app with the google-services.json file through Expo over-the-air updates, but I needed to submit a whole new release on Goole Play Console and go through the whole verification process again in order for the file to be taken into account. Now they deployed my new release with the exact same code and it works.