Different “from:” values received from GCM CCS server upstream msg from the same client

蹲街弑〆低调 提交于 2020-02-27 09:41:43

问题


I'm using the GCM demo application provided by google (repository URL).

When receiving upstream XMPP messages in my app server, consecutive tokens received from the same client differ in their "from" key, is that how it's supposed to be ?

From what I understand, "from" key should always point to a static GCM registration ID obtained by client and thus should not change (at least per each upstream message !).

Here are 3 consecutive upstream messages converted to json I recieve from the app:

{u'category': u'com.google.android.gcm.demo', u'time_to_live': 86400, u'from': u'djrWhYFOLtE:APA91bE4kY9ZdM3N0RAQMJFqedDuTFQsTU6sdhbvJ-zEIWTwzw0kFLs_B05XZ-TgH_5y21VgqAXpWig59EZCSAaSBWKVjUFs-zFLG51uygvWMG6LBh_39IM', u'message_id': test1'}

{u'category': u'com.google.android.gcm.demo', u'time_to_live': 86400, u'from': u'djrWhYFOLtE:APA91bHLqazSKrZGUUEPvMkIKdtWCVIxhdYILfPLeguPR_yDUrProRsCfeP3LQiFzR1o0-Ha-BUMor6pTxKuWmUr9zpE6hIZGEkDV2pcQDJSZUKH3DX91wE', u'message_id': test2'}

{u'category': u'com.google.android.gcm.demo', u'time_to_live': 86400, u'from': u'djrWhYFOLtE:APA91bHAROejFamp-8qwFddOKmUl_EYc_A9HdwnB8ojkUIRX-5kFCjHsnIDQIFa-kWMOdE3NpqU643nTrQnzPFcswTFgd7wBo0KnAub29EEyGP3R01njxz8', u'message_id': test3'}

Is this the expected behavior or am I mistaking something ?

Any help is greatly appreciated.

Thanks !


回答1:


Okay so after a little bit more digging and investigating the issue, seems the "From:" key usually takes a different value upon each upstream message received from the device.

Also sometimes when sending a notification to the device (Using the registration ID taken from the "From:" key), GCM responds with a Nack message, indicating the device has unregistered ("DEVICE_UNREGISTERED"), so I guess Google often invalidates the registration ID inside the "FROM:" after sometime has passed.

What i ended up doing was to send the actual token, received by the client app from GCM, to the server in an upstream message and completely neglecting the "From:" key since it had unexpected behavior. I haven't had any issues so far taking this approach.

Hope this helps someone :)



来源:https://stackoverflow.com/questions/31227589/different-from-values-received-from-gcm-ccs-server-upstream-msg-from-the-same

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!