Expo Push Notifications not working when built on Android

Please provide the following:

  1. SDK Version: 44.0.0
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

Workflow: Managed

Expo Go: Push Notifications work fine for both Android and iOS

iOS Build: Notifications work

Android Build: Notifications do not work

We’ve spent days trying to get expo notifications to work for android builds, following the documentation to the letter.

Documentation we’ve followed:

When trying to register a push token (when the code hits getExpoPushTokenAsync()) we get the following error:
Encountered an exception while calling native method: Exception occured while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Default FirebaseApp is not initialized in this process . Make sure to call FirebaseApp.initializeApp(Context) first.

What we’ve done:

Set up a new FCM project and added our application (ensuring the package id was correct). Downloaded the google-services.json file and put it in the root of our project. Ensured the API key in google cloud messaging matched the key in google-services.json and also ensured that the package name is correct in google-services.json. The API key is unrestricted.

Added the googleServicesFile setting under android in app.json and ensured the package property under android matched our application.

Copied the FCM server key from Firebase, went to the expo UI android credentials and added the key to service credentials.
We have also tried adding the key from expo command line (expo push:android:upload --api-key ) but this adds the key under another application identifier in credentials called “Legacy (Classic Builds)”. This does not work either.

This is what the android section of our app.json looks like:
“android”: {
“package”: “package.name”,
“useNextNotificationApi”: true,
“googleServicesFile”: “./google-services.json”,
“versionCode”: 1,
“adaptiveIcon”: {
“foregroundImage”: “./assets/adaptive-icon.png”,
“backgroundColor”: “#FFFFFF
}

Only extra info we can provide is that we’re building this react native app in place of our existing app so we were reusing our existing android keystore and FCM server key. This didn’t work so we also created a new Firebase project and added the application details again which still did not work.

Not sure what we’re missing, any assistance would be GREATLY appreciated.

Hey @programmedzac
I have been having this problem for a few days now with the same error. I use a project managed with expo and I perfectly followed the integration guide with fcm. I was able to send notifications with apk created with EAS and distributed internally and now nothing works.
@charliecruzan @ide or everyone here can you explain to us what is wrong?

The error message in your post indicates a client-side initialization problem. Even if the FCM API key is not uploaded to Expo, the client-side code needs to initialize correctly. I recommend investigating on the client side more, perhaps by making a small new project that only has the notification and Firebase dependencies to make it simpler to debug.

Your issue sounds different if notifications were previously working for you. These are a few pointers:
Are you getting a client-side error?
Look through adb logs for possible clues.
Are you able to get push receipts (see docs)?
What do they say?

Thanks for your reply @ide
I created a new project with just the expo-notification library to see the behavior and I ended up understanding that this error in my case just appears when I also add react-native firebase to the application. I believe the RNF integration is causing issues with Firebase initialization to fetch the users token. I’ll open an issue with the replication example. Big thanks again

Thanks @ide. We’re in the process of creating a small new project. We’ll let you know how we go.

We created a new bare project, setup android notifications and created a build and it worked fine. Copied all our code to the new project and it still worked. So we have no idea why it wasn’t working or what happened but it’s all good now. Thanks again for your response and suggestion.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.