如果用户在卸载后立即再次安装应用程序,GCM是否删除旧的注册ID? [英] does GCM delete the old registration id if user installs app again immediately after uninstall?

查看:162
本文介绍了如果用户在卸载后立即再次安装应用程序,GCM是否删除旧的注册ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



但是在我的情况下,以下情况发生在我的用户身上。
$ b

情景

1)我的用户安装了应用程序及其设备已向GCM注册。

2)同一用户立即卸载并安装应用程序。第二次生成一个新的注册ID。
$ b $ 3这两个注册ID存储在我的数据库中。

4)现在,这个特定用户正在收到两个推送通知。



现在我有以下问题:

问题:


  1. GCM会在一段时间后删除旧的注册ID吗?
  2. 请建议我如何处理这种情况?

  3. 卸载客户端应用程序注销的方式 可以在卸载
    之后自动取消注册。但是,这个过程不会立即发生。在这种情况下发生的
    是:
    $ b


    1. 最终用户卸载客户端应用程序。

    2. 应用服务器向GCM连接服务器发送消息。

    3. GCM连接服务器将消息发送至设备上的GCM客户端。

    4. 设备上的GCM客户端收到消息并检测到客户端应用程序已被卸载;检测细节取决于客户端应用程序运行的平台。

    5. 设备上的GCM客户端通知GCM连接
      服务器客户端应用程序已卸载。

    6. GCM连接服务器
      标记要删除的注册标记。

    7. 应用服务器向GCM发送
      消息。

    8. GCM向
      应用服务器返回一个NotRegistered错误消息。

    9. 应用服务器应删除注册令牌。

    请注意
    ,注册令牌可能需要一段时间才能完全从GCM中删除
    。因此,即使消息
    不会传递到客户端应用程序,也可能在上面的步骤7
    中发送的消息获得有效的消息ID。最终,注册
    令牌将被删除,服务器将收到NotRegistered错误
    ,而不需要从应用服务器进一步采取任何行动。

    但是,显然您仍然会收到旧注册ID的通知,因为用户在其他问题中声明:



    对于这个问题,有一个名为canonical IDs的功能:


    Canonical IDs

    客户端应用程序触发
    相同设备的多个注册,它可能很难协调状态,客户端应用程序
    可能以重复消息结束。



    实现规范ID可以帮助您更轻松地从这些
    情况中恢复。 规范注册ID是客户端应用程序请求的最后一次注册
    的注册令牌。这是服务器在将消息发送到设备时应使用的ID



    如果您尝试使用旧注册令牌,GCM将
    像往常一样处理请求,但它将在响应的registration_id字段中包含
    中的规范ID。 确保使用此规范ID替换服务器中存储的
    注册令牌,因为
    最终会使旧注册令牌停止工作。



    I came to know that GCM marks registration id for deletion when it is unable to send the next push notification.

    But in my case following situation happened to my user.

    Scenario :

    1)My user installed the app and his device is registered with GCM.

    2)Same user uninstalled and installed the app again immediately. Second time a new registration id is generated.

    3)These two registration ids are stored in my database.

    4)Now this particular user is getting two push notifications.

    Now I have the following questions :

    Questions :

    1. Will GCM deletes the old registration id after some time?
    2. Please suggest me how to handle this situation?

    解决方案

    From the official documentation:

    How uninstalled client app unregistration works

    A client app can be automatically unregistered after it is uninstalled. However, this process does not happen immediately. What happens in this scenario is:

    1. The end user uninstalls the client app.
    2. The app server sends a message to GCM connection server.
    3. The GCM connection server sends the message to the GCM client on the device.
    4. The GCM client on the device receives the message and detects that the client app has been uninstalled; the detection details depend on the platform on which the client app is running.
    5. The GCM client on the device informs the GCM connection server that the client app was uninstalled.
    6. The GCM connection server marks the registration token for deletion.
    7. The app server sends a message to GCM.
    8. The GCM returns a NotRegistered error message to the app server.
    9. The app server should delete the registration token.

    Note that it might take a while for the registration token to be completely removed from GCM. Thus it is possible that messages sent during step 7 above get a valid message ID as a response, even though the message will not be delivered to the client app. Eventually, the registration token will be removed and the server will get a NotRegistered error, without any further action being required from the app server.

    However, it can apparently happen that you still get the notification for the old registration ID, as users state in other questions:

    For this problem, there is a functionality called "canonical IDs":

    Canonical IDs

    If a bug in the client app triggers multiple registrations for the same device, it can be hard to reconcile state and the client app might end up with duplicate messages.

    Implementing canonical IDs can help you more easily recover from these situations. A canonical registration ID is the registration token of the last registration requested by the client app. This is the ID that the server should use when sending messages to the device.

    If you try to send a message using an old registration token, GCM will process the request as usual, but it will include the canonical ID in the registration_id field of the response. Make sure to replace the registration token stored in your server with this canonical ID, as eventually the old registration token will stop working.

    这篇关于如果用户在卸载后立即再次安装应用程序,GCM是否删除旧的注册ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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