When sending messages from your internal server, you need to authenticate the request using the API key associated with the project (sender identifier) ββused to generate the GCM / FCM token.
Due to security restrictions, there is no workaround.
For existing GCM users, the best migration is to import an old project into the Firebase Console. This will allow you to target both the old and the new client, since sender-id will not change. Steps here: https://developers.google.com/cloud-messaging/android/android-migrate-fcm
If this is not an option (you have already created a new project Firebase, different from the previous Google Cloud Project), you have two options:
A simple and recommended approach: change your background code to keep which client launched the gcm / fcm token. Then use the correct API key when sending messages from your server. (The API key associated with the old project for old clients, and the new API key for new clients who use the new Firebase project).
If you canβt change your server at all: in FCM, you can create an additional token for the old SenderID using the API:
FirebaseInstanceId.getInstance().getToken("old-sender-id", "FCM")
Since this token is associated with the old-sender identifier, your back-end will be able to send messages to it using the old project's API key.
Note. this does not affect the Firebase console based on the new sender ID.
This console will only be able to target new customers, which include firebase sdk and the corresponding google_services.json file.
source share