需要从 GCM 迁移到 FCM 吗?

Migration from GCM to FCM needed?

Google 刚刚宣布 Google Cloud Messaging 现已更名为 Firebase Cloud Messaging。这对 GCM 的现有用户意味着什么以及需要进行哪些迁移(如果有)?

云基础架构将基本保持不变,因此现有的 GCM 应用程序应该可以继续正常运行。虽然我还没有发现任何关于 Google 的弃用政策的提及,但 Google 打破现有 GCM infrastructure/SDK/code.[= 是不寻常的(而且他们没有理由这样做) 11=]

FCM 似乎是 GCM 的更好版本,可在多个平台(甚至网络!)上使用并且设置更简单(与 GCM 相比)。迁移指南适用于 Android and iOS

更新:最近通过电子邮件宣布 GCM 现已弃用,并将在明年(2019 年)完全删除,所有 GCM 用户都应开始迁移到 FCM。详情请看我的回答.


除了 , 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 之外,免费 还包含以下功能:

Analytics, App Indexing, Authentication, Dynamic Links, FCM, Invites, Notifications, Crash Reporting, & Remote Config

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.


根据最近 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.

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 是 Firebase 品牌下的新版 GCM。它继承了 GCM 的核心基础架构,以确保我们继续在 Android、iOS 和 Chrome.

  2. 上可靠地传递消息
  3. 是的,GCM 的一些功能已被弃用,但它们支持所有以前的客户端。

  4. 要从 GCM SDK 升级到 FCM SDK,请参阅迁移指南Android

了解更多信息。https://developers.google.com/cloud-messaging/faq

什么是 FCM,我们为什么要使用它?

FCM(Firebase Cloud Messaging)是 Firebase 品牌下 Google Cloud Messaging API 的新改进版本。它具有 GCM 的所有功能以及一些附加功能。根据 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,他们写道:

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 建议在 API 中为 Android 从 GCM 升级到 FCM 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.

GCM 是否已弃用?

GCM 的某些功能已被弃用(请参阅 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.

如何将旧的 Android 应用程序从 GCM 更新到 FCM

来自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.

Google 已扩展 GCM 以将消息发送到 Android 以外的多个平台:iOS 和 Chrome。 Firebase 以跨平台着称,因此 FCM 现在自然适合为 Android、iOS 和移动网络设计的 Firebase 功能套件。

FCM

  • 它是 GCM 的 advance/improved 版本,但具有新品牌名称 Firebase
  • 非常easy/Simplified 客户开发
  • 无服务器控制台,任何人都可以向特定设备发送通知
  • 通知负载:4KB,消息负载:2KB。请注意,通知也包括设备和应用程序信息。
  • 如果设备离线,则每台设备存储 100 notification/messages。