SERVICE_NOT_AVAILABLE some devices on Android GCM
Asked Answered
A

2

2

I made an app using GCM for notifications. I used this tutorial and my code is pretty much identical

http://developer.android.com/google/gcm/client.html

I'm testing on physical devices and on some of the devices I am getting a SERVICE_NOT_AVAILABLE error when I try to register the device with GCM.

I have an exponential backoff setup so it does retry over time.

It works on about half of my test devices the others get a SERVICE_NOT_AVAILABLE error. Looked all over and haven't found a solution yet.

Any help would be greatly appreciated. Thank You!

Appositive answered 20/8, 2013 at 0:26 Comment(0)
B
4

SERVICE_NOT_AVAILABLE might mean that your device can't read the response or there was a 500/503 from the server. You already have a exponential back-off so server side shouldn't be a problem I suppose. See if you have "com.google.android.c2dm.intent.REGISTRATION" to the GCMBroadcastReceiver in your manifest and you are handling that. Check out : GCM SERVICE_NOT_AVAILABLE on Android 2.2 for detailed solution, if you haven't already. Comment if that works.

Beaudry answered 20/8, 2013 at 0:41 Comment(2)
Yes! That did work. Very odd. The Android documentation didn't mention anything about this. Is this just a bug? or is it common practice to get registration ids this way. Also should I implement both methods of getting registration IDs? Or will this BroadCast one just work for everything. Thanks!Appositive
My view is that the android documentation mentions here the following: Note that Google may periodically refresh the registration ID, so you should design your Android application with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times. Your Android application needs to be able to respond accordingly.. So to handle the renewal you might need to do that anyway. Also see this question.Beaudry
J
5

You will also get this error if you simply do not have network connection.

Judsen answered 28/11, 2014 at 9:36 Comment(0)
B
4

SERVICE_NOT_AVAILABLE might mean that your device can't read the response or there was a 500/503 from the server. You already have a exponential back-off so server side shouldn't be a problem I suppose. See if you have "com.google.android.c2dm.intent.REGISTRATION" to the GCMBroadcastReceiver in your manifest and you are handling that. Check out : GCM SERVICE_NOT_AVAILABLE on Android 2.2 for detailed solution, if you haven't already. Comment if that works.

Beaudry answered 20/8, 2013 at 0:41 Comment(2)
Yes! That did work. Very odd. The Android documentation didn't mention anything about this. Is this just a bug? or is it common practice to get registration ids this way. Also should I implement both methods of getting registration IDs? Or will this BroadCast one just work for everything. Thanks!Appositive
My view is that the android documentation mentions here the following: Note that Google may periodically refresh the registration ID, so you should design your Android application with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times. Your Android application needs to be able to respond accordingly.. So to handle the renewal you might need to do that anyway. Also see this question.Beaudry

© 2022 - 2024 — McMap. All rights reserved.