Migration from GCM to FCM needed?
Asked Answered
G

5

45

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?

Gastrocnemius answered 18/5, 2016 at 22:35 Comment(0)
T
33

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.

Tellurium answered 19/5, 2016 at 5:22 Comment(8)
but you can't handle a background message with Firebase Cloud Messaging, or is that possible?Lonnielonny
It is possible if that is a data-only message. What I haven't found is how to have my app handle FCM notifications when the app is not running (sth like a Broadcast Receiver)Vomitory
@NannuoLei By not running, do you mean in the background state or in the killed state?Tellurium
@Tellurium I mean killed state. Backgrounded apps may still run afaik.Vomitory
@NannuoLei Maybe my answer here can give you an idea about GCM/FCM in killed states. Also, I've read somewhere that using the START_STICKY flag may help. Do search around the community, that inquiry is quite common, like this one.Tellurium
Thanks @AL.. I was unaware of the fact that sliding away an app might not kill the whole process. That makes things worse, especially because devs should not start/stop services.Vomitory
Is it possible to leave my finished GCM Android and iOS apps unchanged when switching to FCM, or do the apps need to be touched in any way? I.e. is it sufficient if the server uses the FCM API instead of the GCM API?Tab
On the migration guide I see that server code just need to change endpoint. How about client code? Can I just keep using GCM SDK (GCMRegistrar.register and its current mechanism to send, receive id) after GCM totally shutdown?Fabled
S
107

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.

Semaphore answered 26/5, 2016 at 6:22 Comment(6)
"Yes GCM is depreciated now. See here" This is incorrect. GCM has not yet been deprecated. The thing you linked to was an older GCM API that was deprecated back in 2015 in favor of using InstanceID to get registration tokens for GCM.Dwt
"Yes some features of GCM is already depreciated" is misleading because the "features" you are talking about were deprecated (note: not "depreciated") long before FCM came about. According to this logic, you can also say that some features of Android, iOS, and every other software product are already deprecated because something was deprecated in some version of it.Dwt
@RobiKumarTomar You say it has all features of GCM but what about handleing a incomming message when the app is in the background, can't find any way to do this :sLonnielonny
@KoenVanLooveren please read this firebase.google.com/docs/cloud-messaging/concept-options.Semaphore
yes, I know so then again, you can't write your own implementation for incomming messages in the background, they always go imediately to the system tray, what if I want to send a message to all users to activate a disabled functionality, there will always be a notification in the systemtray, not a fan!Lonnielonny
Should be any changes from server side (api call) in migration from GCM to FCM? Now i have curl calls to android.googleapis.com/gcm/send. What will be new endpoint for GCM?Quahog
T
33

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.

Tellurium answered 19/5, 2016 at 5:22 Comment(8)
but you can't handle a background message with Firebase Cloud Messaging, or is that possible?Lonnielonny
It is possible if that is a data-only message. What I haven't found is how to have my app handle FCM notifications when the app is not running (sth like a Broadcast Receiver)Vomitory
@NannuoLei By not running, do you mean in the background state or in the killed state?Tellurium
@Tellurium I mean killed state. Backgrounded apps may still run afaik.Vomitory
@NannuoLei Maybe my answer here can give you an idea about GCM/FCM in killed states. Also, I've read somewhere that using the START_STICKY flag may help. Do search around the community, that inquiry is quite common, like this one.Tellurium
Thanks @AL.. I was unaware of the fact that sliding away an app might not kill the whole process. That makes things worse, especially because devs should not start/stop services.Vomitory
Is it possible to leave my finished GCM Android and iOS apps unchanged when switching to FCM, or do the apps need to be touched in any way? I.e. is it sufficient if the server uses the FCM API instead of the GCM API?Tab
On the migration guide I see that server code just need to change endpoint. How about client code? Can I just keep using GCM SDK (GCMRegistrar.register and its current mechanism to send, receive id) after GCM totally shutdown?Fabled
E
4

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

Emylee answered 18/5, 2016 at 23:16 Comment(1)
In case you want to migrate, this is the official guide: developers.google.com/cloud-messaging/android/…Internment
Q
2

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.
Quince answered 6/6, 2017 at 5:45 Comment(0)
E
-1

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.

  1. 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.

  2. Yes some features of GCM is deprecated, but they are supporting all previous clients.

  3. 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

Elurd answered 26/5, 2016 at 5:47 Comment(2)
"Yes GCM is deprecated" source?Dwt
some features of GCM are deprecatedElurd

© 2022 - 2024 — McMap. All rights reserved.