Greg Johnson
Greg Johnson

Reputation: 377

GCM messages die a silent death of "Accepted."

Conceptual question, if you don't mind.

We're having a challenge of getting GCM notifications consistently delivered to our Android app, and have kicked the tires of virtually all sides of the code to find nothing wrong. Yet many messages simply conclude their lives at status = "Accepted."

I can confirm that the right gcm_tokens are packaged and sent via POST to https://gcm-http.googleapis.com/gcm/send and that most, but not all, of them are received. I can confirm that all of the gcm_tokens for these messages are being received by the GCM post as we're logging the resulting message_ids. But a message_id does not always translate into a presented notification. FWIW: we're not overriding the default setting for delay_while_idle and time_to_live is set to 1 day.

I'm really at a loss. My remaining two hypotheses: either GCM is materially less than < 100% reliable or we're hitting some edge case where the client is off-network and doesn't get the message once active again. Given this context, anything else we should be checking? Sorry for the nebulous question…we don't know what we don't know.

Upvotes: 4

Views: 236

Answers (1)

Szymon
Szymon

Reputation: 43023

We ran into the same issue.

Our hypothesis is that they are devices that were turned off and stayed turned off ever since. For example, when someone replaces their phone, the old device is switched off or its battery dies. We still hold on to the token on this device and our app is still installed on it. I'm guessing GCM does the same - it cannot contact the device and the device can be turned back on at any time so the token cannot be deemed invalid.

This hypothesis is reinforced by observation that we have more and more tokens like that (over the last few months). This is consistent with the fact that more and more of old devices where people have our app are replaced and turned off. This is also consistent with the GCM messages graph in Google Play dashboard - the number of stored notifications is increasing over time.

I also turned on my old phone after a few months and got a lot of notifications delivered that were previously accepted. Those were notifications that were stored by GCM for 4 weeks (we don't use time_to_live flag) and were not able to be delivered when my phone was offline.

The documentation on this topic is sparse but the best is probably https://developers.google.com/cloud-messaging/concept-options#lifetime.

Upvotes: 3

Related Questions