notifications documentation - received notifications through expo but not through google play

i have build an app and pushed to google play. I have managed to get most parts working, what remains is the notification process. building and testing on expo app (is that expo go?) with both a virtual phone or physical phone i receive notifications as planned. When pushing to the store (internal testing/closed alpha testing) it fails at the notification (getting token I think). The error I’ve managed to pull out is:

Error: Encountered an exception while calling native method: Exception occurred while executing exported method getDevicePushTokenAsync on module ExpoPushTokenManager: Default FirebaseApp is not initialized in this process REDACTED Make sure to call FirebaseApp.initializeApp(Context) first.

Researching this error, others seem to make silly mistakes to do with setting up the app. I have re-followed docs. expo. dev/versions/latest/sdk/notifications/ even removing firebase app and google app, recreating etc.

The documentation makes no mention of importing firebase of initialising it. I have found others talking about it, but they already had it and was simply a case of missing something within the build. gradle file.

First question: do I need to initialise the firebase app and import it? I am trying to send this to Expo to send on the notification… why would I need firebase on the app?

Second question: The documentation feels confusing and incomplete. Can someone at expo take a look and advise? i.e. the setup of the build.gradle looks to be old as it also errored on:
plugins {
id ‘com.android.application’
// Add the Google services Gradle plugin
id ‘com.google.gms.google-services’
}

The only think missing it would seem from all the research is importing firebase, but it doesnt make sense to me.

Thank you in advance!

Hey @askariblue,

The link docs.expo.dev/versions/latest/sdk/notifications/ is an API reference to expo-notifications package. Please see docs FCM for Push notifications docs here: Using FCM for Push Notifications - Expo Documentation to learn more about the required setup for Android.

Also, when you look at the docs.expo.dev/versions/latest/sdk/notifications/ there is a section that for Android Configuration leads to the docs link I mentioned previously for steps to follow. Hope this helps to resove the issue you are facing.

Thanks, reviewing links now. This person also looks to be having the same issue. Will review your docs and likely provide code to see if/where I have gone wrong.

1 Like

Thank you so much for linking the Reddit post here. I’ll get back to them.

Ok I’ve managed to progress past this error. I changed lots, but the last thing I changed was moving the following to the top of the android.app.build.gradle file

plugins {
  id 'com.android.application'
  // Add the Google services Gradle plugin
  id 'com.google.gms.google-services'
}

dependencies {
  // Import the Firebase BoM
  implementation platform('com.google.firebase:firebase-bom:30.4.1')
  // TODO: Add the dependencies for Firebase products you want to use
  // When using the BoM, don't specify versions in Firebase dependencies
  implementation 'com.google.firebase:firebase-analytics'
  implementation 'com.google.firebase:firebase-iid'
  implementation 'com.google.firebase:firebase-messaging'
}

I was using “apply plugin:” because plugins was erroring, but this was then lower in the page. I also read apply plugins is the older way of doing it. There is a lot of confusion on articles etc, date order isn’t always helpful.

Problem fixed, although would suggest having someone review the steps, this seems to be a common pain point and clearer steps or mechanism is highly recommended. Thanks!

I’m not sure how you ended up with this set of instructions to apply. Are you using a bare React Native project (that is created with react native CLI)?

I believe I’m on a workflow… I run eas build --platform android to make the aab. I used to run expo build when testing with the expo app prior to pushing to play store console.

Prior (not immediately before) to this I did move the set channel cmd above the get token. It was still erroring, but I’m not sure if it was the same error. Sorry, a lot of unknowns.

No worries, let me know if the original problem is still not resolved. If you face another issue and can’t find a resolution for it in these forums, feel free to create another post.

Do you mean the bare workflow or managed workflow? Given that you have a build.gradle file, you are actually on the bare workflow. If that is not what you expect then maybe you ran npx expo prebuild or npx expo run:android at some point.

If so, you might want to see the following documentation: expo.fyi/prebuild-cleanup

That I do not know, but from what you’re saying that sounds plausible. I will review the link shared, thank you kindly. In any event, I was successful in building the app. Had additional fun with a picker library which worked on expo but not play store. Replaced with an alternative library but that also required additional tags at the root of the app.

1 Like

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