Android FCM and multiple standalone apps from a single expo app

SDK Version: 37
Platforms(Android/iOS/web/all): Android and iOS

I’ve been using Expo since SDK 32, and never had FCM setup, yet push notifications always worked flawlessly both on iOS and Android.

I just updated to Expo SDK 37, and now standalone apps are throwing the error “Couldn’t get push token for device. Check that your FCM configuration is valid.” So, I’m assuming now I’ll have to include FCM credentials/setup on my build.

That said, I do have a question. The way our app is setup, we have a single expo project (and slug), that is deployed to multiple standalone apps. I understand that the FCM credentials and setup will have to be created for each standalone app, but will the Expo servers be able to handle multiple credentials upload for a single expo app using the command expo push:android:upload --api-key <your-token-here> ?

Thanks in advance.

Edits: typos

We have a similar setup where we have 1 codebase that deploys two different apps.

We solved this in CICD by changing the name, slug and scheme using a node script that modifies the app.json accordingly to the build target. Furthermore we then use release-channels to deploy two different app builds.

This way you could also use a different token per target.

1 Like

This is an interesting solution @dept .

When I first started using expo I tried to do something similar, but I had issues when we tried to send a batch of push notifications to tokens from different “experiences” (I think that’s the naming they have for slug), so I decided to go this route of a single slug to avoid issues.

I might get back to this approach in the future, but, for right now, I’m looking for a simpler solution since we already have more than 100 standalone apps deployed from this single expo slug, and it would be very time consuming to change the way the push notifications are set up for all of them.

Edit: typos

Also, why did it use to work before SDK 37, and now it doesn’t work without the FCM setup? Was this change intentional?

Hey all! Let me try to answer all the questions:

I understand that the FCM credentials and setup will have to be created for each standalone app (…)

No! :slightly_smiling_face: You should be able to share single FCM credentials between multiple standalone apps.

(…) will the Expo servers be able to handle multiple credentials upload for a single expo app (…) ?

Unfortunately no, only one set of credentials can be set to one Expo app (so called experiences identifiable by @username/app-id).

we already have more than 100 standalone apps deployed from this single expo slug

Like if one would run expo build:android in a project’s folder, save the built APK, change some stuff around project and configuration (like icons), rerun expo build:android and so on?

Also, why did it use to work before SDK 37, and now it doesn’t work without the FCM setup?

We’ve decided to stop half-intentionally leaking our Firebase configuration into standalone apps. :sweat_smile: While it was automagically working it wasn’t scaling well and putting configuration in users hands should make it more predictable and configurable.

Was this change intentional?

Yes, the background behind this change can be found at the changelog.

I hope I’ve answered your questions fully!

2 Likes

We do something similar, except with ExpoKit (and eventually Bare). We have a single slug that multiple apps point to, with some switching based on detecting the bundle ID and some resources embedded into the native project. Like @sjchmiela noted, we use a single Firebase project for all of our apps and update google-services.json in the project each time we add a new app. The Firebase project was converted from our old Google GCM project, as we had a few dozen apps already live from a previous Cordova version.

One thing to be careful about with Firebase is that we noticed that, while we can keep creating new Android apps for FCM, when we tried to add Firebase Analytics, we hit a limit. Google/ Firebase were pretty vague about this, but it sounds like some Firebase features use an “oauth account” and some don’t, and the ones that do count against some invisible quota. So, we took out Analytics, just used our Firebase project for FCM, and haven’t had issues since. I wish they would be more transparent about this, since it wasn’t an issue with GCM and actually converting the project over is the only decent migration path for apps that were already using GCM.

2 Likes

Thank you so much @sjchmiela, you did answer (almost) all the questions I have.
I love knowing that I can use a single set of FCM credentials for all of our apps. My only questions on how to approach this is, while setting up the FCM, it asks me the app package id, which is unique for each standalone app. So how would I go about that?

On your question about the multiple standalone apps, we have a folder called apps_config where we have sub folders for each standalone app, with a slight variation of the app.json file, icons, and splash screen. So, whenever I build, I tell it which app.json to use with the --config option, and each standalone app has its own release channel. So I wrote a script to publish to all release channels, where for each release channel, it also uses the correct app.json file for that standalone app. It’s been working very well so far, and I can’t thank you guys enough for creating/maintaining this incredible set of tools @ expo.

Oh, I just realized that you can add multiple apps within the same Firebase project. So I guess that answers my question.
Thanks guys. It turns out that solving this issue will be SO MUCH easier than I thought it would be after your clarification.

1 Like

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