简体   繁体   English

在android上从gcm迁移到fcm

[英]Migrating from gcm to fcm on android

I want to migrate from gcm to fcm in android app. 我想在Android应用程序中从gcm迁移到fcm。 Do I need to send push notification to old users of the android app from gcm or i can send it through the new fcm from server? 我是否需要从gcm向Android应用程序的旧用户发送推送通知,或者我可以从服务器通过新的fcm发送它?

FCM is working fine I'm able to receive push notifications on my device through fcm but I'm not able to send push notifications to old GCM registration tokens from FCM console. FCM运行正常我可以通过fcm在我的设备上接收推送通知,但是我无法从FCM控制台向旧的GCM注册令牌发送推送通知。


Below is the code I've added to my manifest file for fcm to work- 下面是我添加到我的清单文件中的代码,用于fcm工作 -

<uses-permission android:name="com.google.android.z.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application>
    <service
        android:name=".view.activity.MyFcmListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <service
        android:name=".view.activity.MyInstanceIDListenerService">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
        </intent-filter>
    </service>
</application>

I think you can send it through FCM. 我想你可以通过FCM发送它。 To know more about FCM you can check the documentation for frequently asked questions about GCM to FCM . 要了解有关FCM的更多信息,您可以查看有关GCM到FCM的常见问题的文档。 Also if you are starting to migrate from GCM to FCM the you can follow this tutorials: 此外,如果您开始从GCM迁移到FCM,您可以按照以下教程进行操作:

Also for more information, you can check this SO question . 另外,有关更多信息,您可以查看此SO问题

I searched a lot but couldn't find a satisfactory answer. 我搜索了很多,但找不到满意的答案。 So, I applied this fix. 所以,我应用了这个修复程序。

I am continuing using the old method I was using to send push notifications to GCM users and for the users who registers through FCM, I am able to send them push notifications through FCM or Firebase Notification console. 我继续使用我用来向GCM用户发送推送通知的旧方法,对于通过FCM注册的用户,我可以通过FCM或Firebase Notification控制台向他们发送推送通知。

PS You can't send push notification to GCM registration tokens through FCM. PS您无法通过FCM向GCM注册令牌发送推送通知。

I have done POC on this same scenario, and what i observed is given below 我已经在同样的场景中完成了POC,我观察到的是下面给出的

"There is no code change require from client side when you trying to migrate GCM to FCM, and i have tested in both Android and iOS it's working fine. Only change require to do proper configuration in FCM console (ie give correct bundle id and project id (senderid))" “当您尝试将GCM迁移到FCM时,客户端不需要更改代码,我已经在Android和iOS中进行了测试,它运行正常。只需更改需要在FCM控制台中进行正确配置(即提供正确的捆绑ID和项目id(senderid))“

Actually it does work FCM and GCM are the under same hood. 实际上它确实有效FCM和GCM是同一个引擎盖。 A token for GCM works for FCM as well. GCM的令牌也适用于FCM。

GCM tokens retrieved via GoogleCloudMessaging.register() or InstanceID.getToken() will continue to work in FCM without any modification or renewal. 通过GoogleCloudMessaging.register()或InstanceID.getToken()检索的GCM令牌将继续在FCM中工作,无需任何修改或续订。

All you need to do is change your client side implementation as mentioned here . 您需要做的就是更改此处提到的客户端实现。 and update your server endpoint to fcm.googleapis.com/fcm/ 并将服务器端点更新为fcm.googleapis.com/fcm/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM