2

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 !

SpiXel
  • 4,338
  • 1
  • 29
  • 45
  • That's right it should only change if the app's registration token changed. Can you check if the app has the same reg token or that's changing frequently? – Kay_N Jul 10 '15 at 23:47
  • @KayAnn The apps registration token stays the same, but as mentioned above I receive different tokens each time in the from field of the json object. In this case should I update the registration token I keep in my server or that stays the same ? Can I send notifications to the value of From key ? In this case sending notifications to like 100 different tokens will get the notification to device ? – SpiXel Jul 11 '15 at 09:15
  • I don't think sending notifications to 100 tokens would be necessary or efficient. Can you tell me if you have you requested multiple registration tokens for the same app? or has your registration tokens been refreshed a number of times before? Also, do you get any repetitive tokens in "from" param or they are different each time? – Kay_N Jul 13 '15 at 22:31
  • I am also having the same issue and my registration id also remain unchanged during the entire issue. Could it be that there is a bug in the play services library? – e4c5 Jul 27 '15 at 12:02

1 Answers1

0

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

SpiXel
  • 4,338
  • 1
  • 29
  • 45