Different “from:” values received from GCM CCS ser

2019-04-14 16:28发布

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条回答
Lonely孤独者°
2楼-- · 2019-04-14 17:23

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 :)

查看更多
登录 后发表回答