从GCM 2.0迁移到GCM 3.0 InstanceID API [英] Migrate from GCM 2.0 to GCM 3.0 InstanceID API

查看:132
本文介绍了从GCM 2.0迁移到GCM 3.0 InstanceID API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我已经在play store上发布了我的应用程序,并且正在使用该项目。

  compile'c​​om.google.android Google Play服务库版本 7.0 在我的项目中使用Google云消息传递实现推送通知。



Google play服务库版本 7.0 使用旧注册程序使用 register()方法

  GoogleCloudMessaging.register(SENDER_ID); 

但Googel的文件说。


从2015年5月28日起,GCM注册()将被弃用。新应用程序
开发应使用实例ID API来处理创建,
轮换和更新注册标记


InstanceID API 包含在Google Play服务版本 7.5 因此我必须从 7.0 迁移到 7.5 或更多。但是应用程序已经在使用 GCM register()方法的Play商店中。

我已经提到了这个链接,它解释了如何使用 InstanceID 但我不能找到任何迁移指南,从 GCM register() InstanceID



那么我该如何从 GCM register()方法迁移到 InstanceID API



任何帮助都将被赞赏。

解决方案

您只需执行 InstanceId-API ,重新注册设备并将新ID存储在您的服务器上。



这就是他们解释应用迁移的方式从C2DM升级到GCM 此处完全不同的服务,以便升级到最新的 GCM-API InstanceId-API



您应该尝试是否可以混合 InstanceIDs 和旧的 RegIds 发送通知时(我找不到任何提示)。如果不是,你必须保存一个布尔值或任何与服务器上存储的每个ID一起的值,以便能够区分应该使用哪种方法向特定设备发送通知。


Currently I have released my application on play store and in that project i am using

compile 'com.google.android.gms:play-services:7.0.0'

Google play services Library Version 7.0 to implement Push notification using Google cloud messaging in my project.

Google play services library version 7.0 uses old registration procedure using register() method

GoogleCloudMessaging.register(SENDER_ID);

But Googel documentation says.

GCM register() is deprecated starting May 28, 2015. New app development should use the Instance ID API to handle the creation, rotation, and updating of registration tokens

InstanceID API includes in Google play services version 7.5 so i have to migrate from 7.0 to 7.5 or more. But application is already on play store which is using GCM register() method.

I have refer this link which explains how to use InstanceID but i can not find any migration guide to migrate from GCM register() to InstanceID

so how can i migrate from GCM register() method to InstanceID API ?

any help will be appreciated.

解决方案

You just have to implement the InstanceId-API, reregister the devices and store the new IDs on your server.

That´s how they explain migration for apps upgrading from C2DM to GCM here which where completly different services so this will work for upgrading to the latest GCM-API and InstanceId-API as well.

You should try if it is possible to mix InstanceIDs and old RegIds when sending notifications (I could not find any hint about that). If not you´ll have to save a boolean or whatever together with each ID stored on your server in order to be able to distinguish which method you should use to send a notification to a particular device.

这篇关于从GCM 2.0迁移到GCM 3.0 InstanceID API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆