Lets say I have Google Cloud Project (GCP1) with GCM turned on with Client id P1.
Now I have created a standalone Firebase project F2 WITHOUT importing it to GCP1. I have also released F2 to production. (Alternatively, I have imported F2 from an existing firebase.com project into the new Firebase console).
I use a backend server to send push notifications. When I send a push to a GCM token generated via GCP1 from the F2 project, it fails (naturally) because of incorrect client ID. Are there work-arounds to enable use of GCM tokens generated for P1 within F2?
Similarly to how GCM works, the FCM token can change due to token-rotation. Note: the token rotation is a rare-event. Don't expect to see it often. But still, if you care about the token you should implement onTokenRefresh() to be informed of changes.
Firebase Cloud Messaging(FCM), was formerly known as Google Cloud Messaging(GCM). FCM is a cloud platform that provides messages and push notifications for operating systems- ios and Android, and websites as well.
There is currently no way (neither through the Console or through an API) to create a project that is a clone of another project. At the moment you will have to re-create the config data in the new project manually. This user is first on the weekly Google Cloud leaderboard.
When sending messages from your back-end server, you need to authenticate the request with the API-KEY associated with project (sender-id) used to generate the GCM/FCM token.
Due to security restrictions here are no workaround for this.
For existing GCM users the best migration consists in importing the old project into the Firebase Console. This will allow you to target both old and new client, since the sender-id
will not change
Steps here: https://developers.google.com/cloud-messaging/android/android-migrate-fcm
If that is not option (you have already created a new Firebase Project distinct from the previous Google Cloud Project) you have two possibilities:
Easier and recommended approach: change your back-end to store which client originated the gcm/fcm token. Then use the correct API-KEY when sending messages from your back-end. (the API-KEY associated to the old project for old clients, and the new API-KEY for new clients that are using the new Firebase project).
If you cannot change your back-end at all: in FCM you can create an additional token for the old SenderID, using the API:FirebaseInstanceId.getInstance().getToken("old-sender-id", "FCM")
Because this token is associated to the old-sender-id your back-end will be able to send messages to it using the API-KEY of the old project.
Note: this doesn't affect the Firebase Console which is based on the new-sender-id.
That console will be able to target only the new clients that are including the firebase sdk and the associated google_services.json file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With