Please provide the following:
- SDK Version: 44.0.0
- Platforms(Android/iOS/web/all): Android
- 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.