简体   繁体   English

在Android App中从GCM迁移到FCM

[英]Migrating from GCM to FCM in Android App

In Android App, I am migrating from GCM to FCM to send push notification. 在Android App中,我正在从GCM迁移到FCM以发送推送通知。

Then I have a question. 然后我有一个问题。

After migration, Can I send push notification by old GCM token starting from APA・・・? 迁移后,可以从APA ・ ・ ・开始使用旧的GCM令牌发送推送通知吗?

I think when I first open my app from the migration, onTokenRefresh method is not called. 我认为,当我第一次从迁移中打开我的应用程序时,不会调用onTokenRefresh方法。

So the token is still old GCM one. 因此令牌仍然是旧的GCM之一。

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? 如果我无法通过旧的GCM令牌发送通知,那么从迁移中首次打开应用程序时,更改令牌(从GCM到FCM令牌)的最佳方法是什么?

As part of the migration to FCM you will be given a new sender ID token that you should use at the new endpoint. 作为向FCM迁移的一部分,您将获得一个新的发件人ID令牌,应在新端点上使用该令牌。

On the client you need to extend FirebaseInstanceIdService and in there the onTokenRefresh() method will be called with the new token. 在客户端上,您需要扩展FirebaseInstanceIdService并在其中使用新令牌调用onTokenRefresh()方法。 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. 如果您要单独联系客户,则应采用与GCM相同的方式将此令牌发送到服务器。

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

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