My Android app never receives GCM messages on 2.3 devices, but it works on 4.x devices. I can successfully register all devices (2.3 and 4.x). I thought this might have something to do with this issue , but it looks like I have set up the manifest for Android correctly. Can anyone look into my IntentService and BroadcastReceiver and see if they notice any problems? Any help would be greatly appreciated. Please note that onHandeIntent () is never called for Android 2.3 when sending notifications while I have a debugger connected. I checked 4.x devices and they start the debugger in onHandleIntent (). Thanks!
Android Manfest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="my.package" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="my.package.matchtracker.permission.C2D_MESSAGE" /> <permission android:name="my.package.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <receiver android:name=".GcmBroadcastReceiver" 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="my.package" /> </intent-filter> </receiver> <service android:name=".NotificationIntentService" android:enabled="true" /> <activity android:name="com.gigya.socialize.android.GSWebViewActivity" /> <activity android:name=".MainActivity" android:label="@string/app_name" android:configChanges="orientation|screenSize" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Broadcast Receiver:
package my.package; import android.app.*; import android.content.*; public class GcmBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { NotificationIntentService.runIntentInService(context, intent); setResultCode(Activity.RESULT_OK); } }
Notification Intent Service
public class NotificationIntentService extends IntentService { private String TAG = "NotificationIntentService"; public NotificationIntentService() { super(AppConstants.GCM_SENDER_ID); } public NotificationIntentService(String name) { super(name);
android push-notification notifications google-cloud-messaging android-2.3-gingerbread
Daniel
source share