I have an app in Google Play with 5000 downloads.
Of those 5000, 900 have failed to store a GCM Registration ID on my server.
I am concerned about having an 18% failure rate and am struggling to find out why this is happening. It is definitely not an issue passing an Id to my server and storing, so I assume it must be a failure of registration. Has anyone come across anything like this with their projects? Code as below:
// Fired every time the app is booted in Main Activity
private void setupGCM()
{
String gcmRegId = GCMRegistrar.getRegistrationId(this);
if (gcmRegId.equals(""))
{
GCMRegistrar.register(this, AppProperties.GCM_SENDER_ID);
} else
{
// This is well tested and is not the issue
ServerUtils.sUpdatePushToken(this, gcmRegId);
}
}
// GCMIntentService Class onRegistered
@Override
protected void onRegistered(Context context, String registrationId)
{
mContext = context;
if (!registrationId.equals(""))
{
AppProperties.GCM_REGISTRATION_ID = registrationId;
new UpdateGCMRegistrationIdAsync().execute();
} else
{
GCMRegistrar.setRegisteredOnServer(context, false);
}
}
// GCMIntentService Class My Async class for updating Reg Id
private class UpdateGCMRegistrationIdAsync extends AsyncTask<Integer, Integer, Void>
{
@Override
protected Void doInBackground(Integer... params)
{
ServerUtils.sUpdatePushToken(mContext, AppProperties.GCM_REGISTRATION_ID);
return null;
}
}
I just dealt with an issue that may turn out to be the same as yours. Devices with Android less than 4.1 failed to register with GCM. Here is my post from android-gcm google group:
Ok, got it solved. Thanks to J.Carlos Navea and Mark Murphy in this thread:
https://groups.google.com/forum/?fromgroups=#!searchin/android-gcm/onRegister/android-gcm/CqMRN4gVRpY/AGphcX1AuhgJ
The issue was the <category> tag in the receiver declaration. It is required for anything less than 4.1
Use your package name there. Additionally, check to make sure that the <permission> and <uses-permission>
tags use the same string/name. I was getting away with that one as well on 4.1
There are some things that makes the GCM doesn't works, like:
A google accounts that is not syncronized.
In Android 3.2+ when the user "force stop" the application, gcm doesn't works too.
Are you handling the situation where the GCM registration fails? If you're using GCMIntentService, make sure you're implementing the following:
@Override
protected void onError(Context context, String regid) {
// Handle error condition.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With