注册ID重复的GCM [英] Registration ID duplication for GCM

查看:261
本文介绍了注册ID重复的GCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个使用GCM的应用程序。当用户首先打开该应用,应用程序检查共享preferences看用户是否已注册previously.if不是注册的id取自GCM并存储到共享preferences。还存在其中用户ID和注册ID存储第三方服务器。我已阅读并实施下列情形之一者规范ID的问题:

We have an app that uses GCM. When user firstly opens the app,app checks the shared preferences to look whether user is registered previously.if not the registration id is taken from GCM and stored to shared preferences. There is also a 3rd party server where user id and registration ids are stored. I read and implemented the following cases for canonical id issues:

  1. 在发送通知,如果接收到一个新的注册ID(规范标识),旧的注册ID与在第三方服务器的规范标识更新。
  2. 当用户卸载应用程序,并在第三方服务器发送一个通知,卸载应用程序的注册ID,在收到未注册信息,注册ID是从第三方数据库中删除。

作为一个开发者,我们有存储在数据库中的许多注册的ID。因为我们卸载并经常安装应用程序。通常,用户将无法做到这一点。然后,我们考虑使用设备ID作为一个独特的ID为设备并检查用户是否注册previously。它是确定使用Android设备ID呢?我应该怎么考虑prevent多个注册id的设备?这些多注册的ID导致多个推到Android设备。在多个注册ID的主要原因:

As a developer we have many registration ids stored in the database. Because we uninstall and install app frequently. Normally user will not do this. Then we considered using device id as a unique id for the device and check whether user registered previously. Is it ok to use android device id for this? What should i consider to prevent multiple registration ids for a device? These multiple registration ids cause multiple pushes to an Android device. The multiple registration ids mainly caused by:

  1. 在该应用程序卸载,最近重新安装。如何检测用户卸载,安装,并且已拥有注册ID?
  2. 缓存被清除和/或数据被清除为应用程序 最近。如何检测用户清除应用程序数据,并已经哈瓦的注册ID?
  1. The app was uninstalled and reinstalled recently. How can i detect user uninstalled and installed and already have a registration id?
  2. The cache was cleared and/or the data was cleared for the app recently. How can i detect user cleared the app data and already hava an registration id?

什么是操作规范IDS的最佳实践?

What is the best practice for handling canonical ids?

推荐答案

要处理用户卸载的情况,并重新安装应用程序(或清除应用程序数据),我会存储用户ID(或任何标识使用特定的设备上识别一个应用实例)在该装置的外部存储器。当用户卸载应用程序或清除应用程序数据(它仍然可以由用户手动删除,但有什么可以做,没有什么),此存储将不会被抹去。

To handle the situation of a user uninstalling and re-installing the app (or clearing the app data), I'd store the user id (or whatever identifier you use to identify an application instance on a specific device) in the external storage of the device. This storage won't get wiped when user uninstalls the app or clears the app data (it can still be deleted manually by the user, but there's nothing you can do about that).

然后,当你启动应用程序,如果用户数据不共享preferences可用,则尝试将其从外部存储恢复。只有当它不是在外部存储可用,你认为这是一个新的设备上的应用程序的全新安装并注册GCM(此外,你还建议重新注册到GCM,只要您的应用程序的新版本安装)。

Then, when you launch the app, if user data is not available in shared preferences, you attempt to restore it from the external storage. Only if it's not available in the external storage, you assume this is a new installation of the app on a new device and register to GCM (in addition, you are also advised to re-register to GCM whenever a new version of your app is installed).

如果这一切的操作在客户端失败,您仍然有机会从服务器,只要你从谷歌的反应得到规范注册ID删除重复注册的ID。

And if all this handling at the client side fails, you still get a chance to remove duplicate registration IDs from the server, whenever you get a canonical registration ID in the response from Google.

这篇关于注册ID重复的GCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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