关于GCM中的canonical id's(谷歌云讯息) [英] regarding canonical id's in GCM (google cloud messaging)

查看:209
本文介绍了关于GCM中的canonical id's(谷歌云讯息)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近为推送通知应用程序设置了GCM。服务器API在Node.js中,因此我使用节点模块node-gcm将通知推送到gcm服务器。

我们注意到有时候数据包没有传送给最终用户。在进行了一些搜索之后,我调整了一些帮助提高可靠性的设置。



我将旧设置更改为以下新设置:




  • delayWhileIdle标志从真到假,


  • collapseKey到一天中的时间而不是演示


  • timeToLive改为7200而不是3




我也读过关于规范id的。 谷歌页面规范注册ID被定义为



我在发送消息时记录了结果。结果中的标准ID是0.这是什么意思?结果如下:

  {
multicast_id:9180653668551804000,
成功:1,
失败:0,
canonical_ids:0,
results:[{message_id:'0:1415521804106240%0209acc19067cebd'}]
}

这里的帖子在stackoverflow 建议替换注册ID与规范的身份证。我不清楚什么时候更换,什么时候不更换。

在我的服务器数据库中,当应用程序安装并与用户的记录一起存储在数据库中时,会请求reg_id。还有什么是这些字段,如message_id和multicast_id在结果?

解决方案


  1. 规范id = 0 意味着您的推送服务器使用的注册ID不会被替换为规范ID,即通常GCM服务器将响应canonical_id = 0。如果由于某些原因,服务器发送推送不是真正的注册ID GCM服务器的响应将是:



    GCM HTTP状态:200
    GCM响应正文:

      {
    multicast_id:7036866281258904189,
    success:1,
    failure:0,
    canonical_ids :1,
    的结果:[
    {
    的registration_id: APA91bH88lV-u5XNdJoF5p0W2d0F_z_7AM6_cjx1e62s83bvDZYcdU_lkmRaFdnkZ5PPUBdYssfpB2QygMW5V0kTqVpV4atCyKpnBEkVnd_YTY0qr4V9oHSyYpv_HIDGNzpfHyGfXz5fWCKnlnACHr37y1zT91JcrHyUMR6DB15WzwjAE1QtloI,
    的MESSAGE_ID: 0:1415529915241995%64ac3713f9fd7ecd
    } b
















    $ b <现在, cannonical_ids = 1 ,这意味着您的服务器必须将新的值替换为现有的注册ID,您会看到相应的值。如果用户重新安装客户端应用程序,这种情况很容易重现,但您的推送服务器不知道它,并且GCM服务器将响应新的注册ID。您可以在我的测试推送服务器上测试这种情况。


    1. @ mandeep_m91至于message_id和multicast_id我只是建议您阅读文档。在练习中,我还没有使用这个字段


    we have recently set up GCM for an application for push notifications. The server api is in Node.js so I am using the node module node-gcm for pushing the notifications to gcm server.

    We noticed sometimes the packets were not getting delivered to the end user. After doing some search, I tweaked some of the settings which helped a lot to improve the reliability

    I changed the older settings to the following new settings:

    • delayWhileIdle flag from true to false,

    • collapseKey to time of day instead of 'demo'

    • timeToLive to 7200 instead of 3

    I also read about canonical id's. The google's page "A canonical registration ID is defined to be the ID of the last registration requested by your application. This is the ID that the server should use when sending messages to the device."

    I logged the result while sending the message. The canonical id in the result was 0. What does this mean ? Here is the result:

    { 
      multicast_id: 9180653668551804000,
      success: 1,
      failure: 0,
      canonical_ids: 0,
      results: [ { message_id: '0:1415521804106240%0209acc19067cebd' } ] 
    }
    

    The post here on stackoverflow suggests to replace the registration id with the canonical id. I am not clear on when to replace and when not to.

    In my server's database reg_id is requested when app is installed and stored with the user's record in the database. Also what are these fields like message_id and multicast_id in the result ?

    解决方案

    1. The canonical id = 0 means that registration id which your push sever used is OK and not should be replaced by canonical id, i.e. often GCM server will be response canonical_id = 0. If for some reasons your server sends push on not actual registration id GCM server's response will be:

      GCM HTTP status: 200 GCM response body:

      {
          "multicast_id": 7036866281258904189,
          "success": 1,
          "failure": 0,
          "canonical_ids": 1,
          "results": [
              {
                  "registration_id": "APA91bH88lV-u5XNdJoF5p0W2d0F_z_7AM6_cjx1e62s83bvDZYcdU_lkmRaFdnkZ5PPUBdYssfpB2QygMW5V0kTqVpV4atCyKpnBEkVnd_YTY0qr4V9oHSyYpv_HIDGNzpfHyGfXz5fWCKnlnACHr37y1zT91JcrHyUMR6DB15WzwjAE1QtloI",
                  "message_id": "0:1415529915241995%64ac3713f9fd7ecd"
              }
          ]
      }
      

    Now, cannonical_ids = 1 and it means that your server has to replace existing registrtation id on new value which you see in response. This case easy reproduce if user reinstall your client application, but your push server doesn't know about it and GCM server will pass in response new registration id. You can test this situation on my test push server

    1. @mandeep_m91 as to message_id and multicast_id i just suggest you read documentation. In a practise i haven't use this fields yet

    这篇关于关于GCM中的canonical id's(谷歌云讯息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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