Migrating from GCM to FCM in Android App - android

In Android App, I am migrating from GCM to FCM to send push notification.
Then I have a question.
After migration, Can I send push notification by old GCM token starting from APA・・・?
I think when I first open my app from the migration, onTokenRefresh method is not called.
So the token is still old GCM one.
If I cannot send notification by old GCM token, what is the best way to change token(from GCM to FCM token) when I first open my app from the migration?

As part of the migration to FCM you will be given a new sender ID token that you should use at the new endpoint.
On the client you need to extend FirebaseInstanceIdService and in there the onTokenRefresh() method will be called with the new token. You should send this token to your server in the same way as you did for GCM if you want to contact your clients individually.

Related

Android RegistrationId push Notification

I would like to get the registrationID from my app. Does the registrationid exist before your app gets sent to the store ? If it doesn't how to I test push notifications ?
The device registration token that FCM uses to deliver messages for your app to a device is created when an app with the Firebase Cloud Messaging SDK is installed on that device. Your app does not need to be in the Play store for that to happen. See the documentation on accessing the registration token to learn how to get that token in your application code.
The easiest way to test delivery is to send a notification through the Firebase console, in which case you only need the FCM registration token or a topic (that your application code is subscribing to).
To send a message to the device from (server-side) code, you need the FCM token (or topic again), the FCM server key (or OAuth authorization), and the sender ID.

Android APP migrates from GCM to FCM. Old GCM tokens do not work

The document from Google says:
GCM tokens retrieved via GoogleCloudMessaging.register() or
InstanceID.getToken() will continue to work in FCM without any
modification or renewal.
But when I update my APP to FCM. The old GCM token which stores in my Server does not work anymore. When I tried to send a push message, the Google Message server response the error message, not registered. Does anyone ran into the same problem?
Based from the documentation of GCM and FCM FAQ:
Will your existing GCM tokens and token handling still work?
Your GCM and FCM registration tokens are mutually interchangeable; you
can send to existing GCM tokens through the FCM HTTP server APIs. For
GCM and FCM token handling, remember:
If you store and send to specific tokens, be sure to implement the token refresh method to ensure your tokens are always up to date
iOS devs should avoid calling .getToken(authorizedEntity,scope) unless there is a need to enable multiple senders. Use
FirebaseInstanceId.getInstance().getToken() instead.

How to get new token when migrate from GCM to FCM for existing app

I have application with GCM it's working fine,now i want to migrate from GCM to FCM.
I have used this document for migration,everything working fine for new installed apk.It call the onTokenRefresh and i have used that token for future use.
Issue is
When i update new app(have FCM code) on existing app(have GCM code).it will not call onTokenRefresh method.So how can i upload new token on server for future use when apk is updated not a fresh installed.
In this case i have also tried FirebaseInstanceId.getInstance().getToken(); it but provide a new token but onTokenRefresh not get executed.
Can any one provide a solution for this,how to identify app get updated from GCM to FCM so i will upload new token on server.

send notification from firebase console to old users with gcm tokens?

I have questions about migrating from gcm to fcm.
we are going to migrate from gcm to fcm. we have lots of users with gcm tokens and we have already sent them push notifications from onesignal panel. now when we migrate to fcm,what happens to old users with gcm tokens? I know if we force our users to update their android version to new version(the one with fcm) the new fcm token will be generated for users. but what if we don't want to force our users to update? Is it possible to send notification from firebase console to old users that have gcm tokens?
I have already done the migration procedure according to this link:
https://developers.google.com/cloud-messaging/android/android-migrate-fcm
I tried same but gcm people is not getting notification so i make 2 payload 1 for fcm and 1 for gcm and sending massage for both fcm and gcm at same time so i m getting gcm notification but you have to handle crash for gcm notification in fire-base app. means it will crash when you receive gcm notification on fcm but when fcm notification come it will diaplay

Is possible to ask GCM server unable to push notification to expired/obsolete registration id?

I'm develop an android application use GCM, when I upgrade app version, I must register GCM registration id again, and GCM server return new registration. But when push a notification to both old registration id and new registration id, GCM accept all of those. GCM will returns response "send successfully" with message include newest registration id.
{"multicast_id":4727651484309285125,"success":1,"failure":0,"canonical_ids":1,"results":[{"registration_id":"APA91bEVF3NWBSdTy9JuEAQCs3DEg-uLYR1F5j7v4_vmbW0ccsSDpEMLRF4SPoo2U4Ikqfn9oCyv4OYZnW6sUSBo_AjL6-07Ex3NX8vYgK0SSr6JriP4wkHF0a-WG2vRV5IAsg3gn7pY","message_id":"0:1445568030699378%9fffe997f9fd7ecd"}]}
Is possible to ask GCM disable old registration, so any attempt to push message to old registration id will be rejected.
I want to be able to push notification to newest registration only.
Do anyone have any idea?
In some cases GCM will still send messages to tokens that should no longer be used. When you send a message and receive a canonical ID, which is what the registration_id in results is. You should update your server side list of tokens by removing the token that resulted in a canonical ID in the response, using the canonical ID instead.

Categories

Resources