Do I need to migrate GCM to FCM on client side? - android

I have the old android app on Play Store which I am not going to update anymore because of making a new app.
Do I need to migrate GCM to FCM in my old android app?
Many sources say:
You have to change your client side... blabla... etc...
but GCM and FCM FAQ says:
GCM tokens will continue to work on client devices.

Existing installs of client-side apps receiving notifications will continue to work for the foreseeable future. You don't need to get new tokens for all users. The existing tokens from GCM will continue to work
But from mid-April:
You won't be able to compile code using the old client-side APIs on a newer SDK/Google Play Services anymore
You won't be able to call the GCM REST API to send messages anymore
New installations of your existing GCM-using app may not be able to get a token.
To compile against the new SDK/Google Play Services, you will need to make changes to your client app to migrate to Firebase Cloud Messaging from GCM. This involves changes to the build.gradle, to AndroidManifest.xml and to your code, as described in Migrate a GCM Client App for Android to Firebase Cloud Messaging.

You need to update your client code and migrate to FCM. Because it is officially announced to do migration and it is very likely that from a point, for example by one of the android updates, they stop supporting old api callbacks and if so you will lose part of your users.
So my advice is to do the migration as it has been long enough so far that they had supported GCM along with supporting FCM and they can't and won't do it forever.

Related

About GCM implementation Android application after April 11, 2019(GCM is abolished)

I would like to migrate a GCM Client App for Android to Firebase Cloud Messaging.
In the Firebase console, I selected my GCM project from the list of existing Google Cloud projects, and add Firebase,
and now, even if I update my server code to use new FCM endpoints for sending messages, Push notification will be sent to the existing GCM version Android application It has arrived.
Will Push notifications be sent to GCM version applications after April 11, 2019(GCM APIs will be removed)?
It seems that such meaning is written in GoogleDeveloper (※ https: //firebase.googleblog.com/2018/04/time-to-upgrade-from-gcm-to-fcm.html).
But my android app does not use "GcmListenerService" which appears in Google official migration guide.
my android app is an old implementation just after migrating a C2DM Client for GCM Client,
is the old implementation right after moving from C2DM to GCM, is my android app OK?
Current implementation
Start Service with the intent of
com.google.android.c2dm.intent.REGISTER specified, and register
registration ID
Receive BroadCast of com.google.android.c2dm.intent.REGISTRATION,
obtain registrationId and send it to business server
Receive BroadCast of com.google.android.c2dm.intent.RECEIVE,
receive push notification from the server.
For business reasons,
It is difficult to forcibly update the current user's Android application from the GCM version to the FCM version.
Thank you.
From the same blog post (emphasis mine):
If you have projects that are still using the GCM APIs, you will need to update your client and server code to use FCM before April 11, 2019.
With that, it seems you need to update the client app as well. There isn't any documentation that says that app versions that are still using GCM code would cease to receive messages, but the behavior to receive will no longer be guaranteed after the said date.
Business wise, you may not force the update, but make it so that users are encouraged to update by saying something along the lines of "An update is necessary to use the full potential of the app."
I came to the following conclusion, based on this (from further down the same blog post):
What happens to my users who don't update their apps?
As long as users have GCM logic in their apps, they will still receive messages. FCM is backwards compatible with GCM, so even if you don't update your server endpoint now, you can still update your app's logic, and vice versa.
And from the FAQ:
Note that client SDKs and GCM tokens will continue to work indefinitely. However, you won't be able to target the latest version of Google Play Services in your Android app unless you migrate to FCM.
So I'm going to play it safe and have both my server and app updated with FCM before the deadline.
But to answer your question, users who have not upgraded to the FCM version of the app should still continue to receive push notifications after the April 2019 deadline.

Unregister from GCM and register on FCM

My android app uses GCM and urbanairship for push notifications.
Now Google has deprecated GCM and is recommending to switch to FCM.
The problem is I don't have access to the Google account which was used to set up GCM as it was set up using one of the developers account who has left. So I can not migrate from GCM to FCM as told in the migration tutorials.
In this scenario, how can I switch to FCM using a different Google account keeping in mind that I use urbanairship?
I want to preserve the registration tokens, or get them replaced without asking customers to uninstall and reinstall the app.
Is it possible that the app registers itself with FCM when I roll down an update?
The problem is I don't have access to the Google account which was used to set up GCM as it was set up using one of the developers account who has left.
This is not an uncommon situation. What I would suggest is contacting Google Support about the GCM Project. It would be best for you to get access to current project, specially if you are the one managing/using it.
After getting access, you could then migrate it to Firebase as needed.
In this scenario, how can I switch to FCM using a different Google account keeping in mind that I use urbanairship?
You can't switch to a different account. However, you could modify your app to receive messages from a different project. I haven't used UrbanAirship before, but AFAIK, if they are using GCM underneath their service, then they too should be handling the FCM migration part.
Is it possible that the app registers itself with FCM when I roll down an update?
In order to register an app is for it to call getToken(). So technically, yes. But you would have to handle pairing/saving the token to it's corresponding user.
With all that said, I would strongly suggest you contact Google Support first.
Here is how I solved the problem:
1. Created a new Google FCM account.
2. Created a new project in Urbanairship console using keys from new Google FCM account.
3. Updated the backend code to send notifications twice - once for old urbanairship project and once for new project. Out of the two attempts, one will fail for sure and one will succeed for sure as customer will be using either of the two versions of the app.
4. Customers using old version of app will have registation tokens which are available with old urbanairship project. Customers using new version of app will have registation tokens which are available with new urbanairship project.
5. When customer updates the app, urbanairship takes care of registering the token with new FCM account server. I don't have to do anything here. This was not expected as token is updated upon fresh installation and not during updates.
So to summarize:
UA Project Old -> Google GCM -> Device with old app version
UA Project New -> Google FCM -> Device with new app version
Here is the FCM Urban Airship migration guide. Assuming you are able to recover your GCM account you only need to follow that guide with your existing sender ID. If you change accounts, you will have to configure the new FCM project API key in the Urban Airship dashboard. The SDK will automatically update all the channels with the new registration token. During the transition period, only devices that have updated will be able to receive push.

Can I use both GCM and FCM in my app?

I have an android project in which GCM is implemented. Back-end (server) is already coded suitably with GCM.
Now is it possible to add firebase (FCM) in my project and work in parallel with GCM? I cant migrate to FCM because it is impossible to change my back-end code as it is a big project and too much code is there. Has anyone done something like this?
Please help. Thanks in advance.
Though my particular case might be a bit specific, because the project I am involved in has a very specific backend, it seems to me FCM interoperates well with GCM, i.e you can have both in your app, GCM and FCM broadcast receivers / receiver services, and they will both work as well with no conflicts.
This has a huge advantage because you don't have to decide with migration at once, you can do this more gradually.
Well done, Google!
No, you can not use both FCM and GCM at same time. GCM is the old version and that it is strongly recommended to use FCM.
Why is Google Cloud Messaging (GCM) part of Firebase? How does it relate to Firebase Cloud Messaging (FCM)?
Google is investing in Firebase, making it our unified mobile
platform.
Over the last few years, we have expanded GCM to send messages to
multiple platforms beyond Android: iOS and Chrome. Firebase is known
for being cross platform, so FCM now makes a natural fit in the
Firebase suite of features designed for Android, iOS, and mobile web.
Another core value of Firebase is cross-feature integration. We are
adding the ability for other Firebase features to easily send messages
via FCM. For example, you can use Firebase Notifications to send
reengagement messages to your users.
We think that GCM will be even more useful to developers as an
integrated part of Firebase. You can still get the same great product,
now under a new name: "Firebase Cloud Messaging," or FCM for short.
Is GCM going to be deprecated?
We will continue to support the current version of GCM Android and iOS
SDKs because we know a lot of developers are using GCM SDKs today to
handle notifications, and client app upgrade takes time.
But all new client-side features will be added to FCM SDKs only moving
forward. You are strongly encouraged to upgrade to FCM SDKs.
You can get more details here
As per FAQ you don't need additional server configuration when you're migrating your client app from GCM to FCM, so just use FCM in your android app.
Here's the docs on how to migrate your app
I find the problem to use both GCM and FCM together. You will get to different deviceToken and one of these token get NotRegistered error.
For my FCM token always get NotRegistered error but the app is active and not uninstalled and my GCM token is valid and gets a push notification.

Smooth GCM to FCM transition

Anyone have experience with it? I'm investigating migrating, but as we already have the app released with GCM, with thousands of users and thousands of notifications daily, I'm reluctant for fear of disrupting existing service. Did anyone manage a smooth transition?
Specifically, in the tutorial (https://developers.google.com/cloud-messaging/android/android-migrate-fcm) step one is 'Import Google Project'. Is this a one-way operation? Will existing GCM server solution and deployed GCM apps continue to work?
Or is the best bet to create a new project, and maintain two server solutions until the GCM deployed apps are phased out?
Importing your Google project into Firebase is a one way operation, however this is not a destructive operation, your current project will have required APIs turned on and necessary API keys will be generated for use with Firebase, but you can still manage that project from the Google Developer console if you decide not to continue using Firebase.
Your present server solutions will continue to work as before. I would go with importing your project to Firebase. It will be much easier than having to migrate your backend to a new project.
note:
If you were using pre InstanceID tokens for device IDs then they will not work in the Firebase console or with topics. So you would have to maintain a mapping of which users you can send to using the Firebase console and/or topics. If your were using GCM with InstanceID then there is nothing to do since FCM also uses InstanceID. You can use the FCM REST API to send to ALL tokens, InstanceID or pre InstanceID.
Be sure not to use GCM and FCM libs in the same client app. You can find issues when generating tokens and handling received messages.
First test out, There are many things to take care in FCM.
Major issues :
White Notification Icon while app is in background or killed.
App hangs after opening closing multiple times.
Read these issues to decide:
Firebase push notifications update DB
https://stackoverflow.com/a/37626817/1507602
How to handle notification when app in background in Firebase
After Upgrading to Google Play Services 9.0.0, App Hangs in DynamiteModulesC
Notification Icon with the new Firebase Cloud Messaging system

Migration from GCM to FCM needed?

Google just announced that Google Cloud Messaging is now Firebase Cloud Messaging. What does this mean for existing users of GCM and what migration (if any) are needed?
What is FCM and why should we use it?
FCM (Firebase Cloud Messaging) is a new, improved version of the Google Cloud Messaging API under the Firebase brand. It has all the features of GCM as well as some additional features. Per the Firebase FAQ, it "inherits GCM’s core infrastructure, with new SDKs to make Cloud Messaging development easier". Google explained their decision to release FCM in their Cloud Messaging FAQ, where they wrote:
Firebase is known for being cross platform, so FCM now makes a natural fit in the Firebase suite of features designed for Android, iOS, and mobile web
Google recommends upgrading from GCM to FCM in their APIs for Android Release Notes. Reasons for doing so are given in the Firebase FAQ:
Benefits of upgrading to FCM SDK include:
Simpler client development. You no longer have to write your own registration or subscription retry logic.
An out-of-the-box notification solution. You can use Firebase Notifications, a serverless notifications solution with a web console that lets anyone send notifications to target specific audiences based on Firebase Analytics insights.
Is GCM deprecated?
Some features of GCM are already deprecated (see https://developers.google.com/cloud-messaging/android/legacy-regid, for example) and now in the coming days GCM is going to be fully deprecated. Google says:
We will continue to support the current version of GCM Android and iOS SDKs because we know a lot of developers are using GCM SDKs today to handle notifications, and client app upgrade takes time.
But all new client-side features will be added to FCM SDKs only moving forward. You are strongly encouraged to upgrade to FCM SDKs.
How to update old Android applications from GCM to FCM
From https://developers.google.com/cloud-messaging/android/android-migrate-fcm:
Import your GCM project as a Firebase project:
In the Firebase console, select Import Google Project.
Select your GCM project from the list of existing projects and select
Add Firebase.
In the Firebase welcome screen, select Add Firebase to your Android
App.
Provide your package name and SHA-1, and select Add App. A new
google-services.json file for your Firebase app is downloaded.
Select Continue and follow the detailed instructions for adding the
Google Services plugin in Android Studio.
Update: There was a recent announcement via email that GCM is now deprecated and will be completely removed next year (2019), and all GCM users should start migrating to FCM. For more details, see my answer here.
In addition to what Pritam Baral's answer, note that FCM's core is composed of GCM itself. There is no actual need to migrate to it, but it is encouraged, since when migrated to FCM, all of the features tied to it will be available for use. When referring to the Firebase Official Pricings Page, the features that are included for free are:
Analytics, App Indexing, Authentication, Dynamic Links, FCM, Invites, Notifications, Crash Reporting, & Remote Config
Pre-IO GCM implementations should still work for a longer time in the future, as stated in the GCM and FCM FAQs:
We will continue to support the current version of GCM Android and iOS SDKs because we know a lot of developers are using GCM SDKs today to handle notifications, and client app upgrade takes time.
But all new client-side features will be added to FCM SDKs only moving forward. You are strongly encouraged to upgrade to FCM SDKs.
As per the recent highlights:
Firebase Cloud Messaging builds on and improves the Google Cloud Messaging API. You can keep using Google Cloud Messaging with com.google.android.gms.gcm, but we recommend upgrading to com.google.firebase:firebase-messaging.
The cloud infrastructure will mostly remain the same, so existing GCM apps should continue to work fine. Although I haven't found any mention of a deprecation policy from Google yet, it would be unusual for Google to (and they have little reason to) break existing GCM infrastructure/SDK/code.
FCM seems like a better version of GCM, being available on multiple platforms (even web!) and simpler to setup (compare to GCM). Migration guides are available for Android and iOS
Google have expanded GCM to send messages to multiple platforms beyond Android: iOS and Chrome. Firebase is known for being cross platform, so FCM now makes a natural fit in the Firebase suite of features designed for Android, iOS, and mobile web.
FCM
it is advance/improved version of GCM but with new brandname Firebase
very easy/Simplified client development
Server-less console where anyone can send notifications to specific device
Notification payload: 4KB, Message payload: 2KB. Note that the notification includes device and app information too.
Stores 100 notification/messages per device if the device is offline.
Firebase Cloud Messaging (FCM) is the new version of GCM. It inherits
the reliable and scalable GCM infrastructure, plus new features! See
the FAQ to learn more. If you are integrating messaging in a new app,
start with FCM. GCM users are strongly recommended to upgrade to FCM,
in order to benefit from new FCM features today and in the future.
FCM is the new version of GCM under the Firebase brand. It inherits GCM’s core infrastructure to make sure we continue to deliver messages reliably on Android, iOS and Chrome.
Yes some features of GCM is deprecated, but they are supporting all previous clients.
To upgrade from GCM SDKs to FCM SDKs, please see the guides for migrating Android
For more information.https://developers.google.com/cloud-messaging/faq

Categories

Resources