Can't use expo-notifications after converting managed workflow app into standalone app

  1. SDK Version: 41
  2. Platform: Android
  3. Expo library: expo-notifications

Hello!

I created an app with the managed workflow of expo (expo init …), in which I used expo-notifications (without fcm). Everything worked out fine. Now I converted it into a standalone app (expo android:build -t apk), and I followed the instructions on

https://docs.expo.io/push-notifications/using-fcm/ 

to continue using expo-notifications without Expo Go.

That means, I created a firebase project, added my android app with the package name provided by app.json, and downloaded and checked the google-services.json file.
The one thing I couldn’t do was step 3 of integrating my app to the firebase project, “Add Firebase SDK”, since it is a standalone app which used to be a pure expo app (created through the command “expo init …”), and I don’t have the android folder or any gradle files described in that step.
I am relatively new to firebase and react native (to coding in general), so I don’t understand how I can execute this step without my app being a bare workflow app or pure react native (or if I even can skip step 3 in that case).

After “finishing” the app integration into my firebase project (missing step 3), I uploaded the credentials via expo push:android:upload --api-key , being replaced by the server key token in the cloud messaging tab in the firebase project settings.

My problem now is, that due to the transformation of my app, I can’t use expo-notifications anymore (the token is not generated in the first place), and I don’t know if it’s because of me skipping step 3 or if it’s something else.

I changed nothing in my code, since the documentation says using managed workflow it’s not necessary to adapt the code after transforming the app into a standalone one. Once I tried replacing

token = (await Notifications.getExpoPushTokenAsync()).data;

with

token = (await Notifications.getDevicePushTokenAsync()).data;

in the async function registerForPushNotificationsAsync(), just in case. Didn’t change anything, though. As I said, sorry, I am very unexperienced in that area, probably I’m just missing something important.

Please help me, I have a deadline (till Wednesday at the latest) and I just can’t figure this out.
Thank you very much in advance!

Cheers,
Bianca

If the token isn’t generated, you should check for an error either by try/catching, or check the native android device logs. There are a couple other reports of the same issue and it’s usually been a configuration problem, so once you find the error message make sure to Google search for it

Thank you, you’re right, the adb logcat didn’t provide much, but via try/catch I got the following error:

“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 googled it, and while the error came up a few times, it doesn’t seem as if anybody has found the cause/ a solution for it yet, or at least I haven’t found anything during my search.

Here is the same issue. To fix it, you should follow this guide

Thank you, I did follow it, but I didn’t know if I was missing something because it still didn’t work. My colleague figured it out today: I added more than one app to my firebase project, which lead to an entry for each one of them in my google-services.json file. Apparently it did the trick to erase the data regarding my other apps (or to only add one app to a project in the first place).
I also forgot to update the .apk file each time I rebuilt my app, which might have contributed to my problems.

Thank you very much for your help!

1 Like

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