There is something you need to be aware of if you are placing your GCM (Google Cloud Messaging, aka push notifications) service (the one extending from GCMBaseIntentService) in a package other than the main application package. The default implementation of the GCMBroadcastReceiver class, whcih is part of the GCM library assumes that your service is going to be in the main application package. If the service is in a different package though, then it will not be able to be started by the broadcast receiver and if you are debugging your app it will look like your app requests a Registration ID from the Google servers, but then everything dies off and you are not getting a response back.
What you need to do in this case is extend the GCMBroadcastReceiver class and override the getGCMIntentServiceClassName method to return the package name of the service and the service class name. So for example, if your service was called GCMIntentService in package com.mycompany.mainpackage.somepackage, you would return: “com.mycompany.mainpackage.somepackage.GCMIntentService”. Here is an example of the extanded GCMBroadcastReceiver class:
public class GCMMyBoadcastReceiver extends GCMBroadcastReceiver {
protected String getGCMIntentServiceClassName(Context contest) {
return "com.mycompany.mainpackage.somepackage.GCMIntentService";
}
}
Also, do not forget to update your manifest file to make sure that the new extended broadcast receiver is used:
<receiver android:name="com.mycompany.mainpackage.somepackage.GCMMyBoadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.mycompany.mainpackage" />
</intent-filter>
</receiver>
This little detail wasted a coule of hours of my time trying to figure out what I did wrong. Unfortunatly this detial is not well documented (not even mentioned) in their GCM implementation tutorial.
Excellent!!
This is the only site where I found the solution for the GCM-in-other-package problem (not even found on stackoverflow). Works like charm now.
Thank you so much.
Rick
Really great work. As Rick said this is the only place explains in GCMService in other packages. Thanks
Pingback:ordering enclomiphene uk how to get
Pingback:en las farmacias simi puedo comprar kamagra
Pingback:discount androxal generic order
Pingback:purchase dutasteride without a script
Pingback:cheapest buy flexeril cyclobenzaprine cheap australia
Pingback:buy cheap gabapentin uk generic
Pingback:online order fildena purchase usa
Pingback:how to order staxyn usa mastercard
Pingback:online order itraconazole for sale usa
Pingback:buying avodart generic prices
Pingback:cheapest buy rifaximin australia to buy
Pingback:get xifaxan generic best price
Pingback:kamagra v austrĂ¡lii