1

I have push enabled for my application and my manifest is as seen below:

Package Name:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.norton.mobile"
android:versionCode="1"
android:versionName="1.0" >

My receiver is as below:

<receiver
        android:name="com.pravaa.mobile.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <!-- Receives the actual messages. -->
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="com.stanley.mobile" />
        </intent-filter>
    </receiver>

With the above configuration i am able to receive notifcation succesfully on any device with OS > 4.1, but not on devices with OS < 4.1. On modifying the receiver category configuration to **<category android:name="com.norton.mobile" />** i was able to sucessfully receive notifications even on devices with OS < 4.1. I do understand that the docs say "A receiver for com.google.android.c2dm.intent.RECEIVE, with the category set as applicationPackage." But how does it work for devices with OS > 4.1 although the category does not match the applicationPackage. Does someone know the reasoning behind this? Thanks in advance.

S.A.Norton Stanley
  • 1,833
  • 3
  • 23
  • 37

2 Answers2

1

Maybe you wrote a wrong category name, and it worked cause a category name is not required above OS 4.1.

" Notice that android:name in the category tag must be replaced by your application's package name (and the category tag is not required for applications targeted to minSdkVersion 16 and higher).

http://developer.android.com/google/gcm/helper.html#android-app "

Chan Baek
  • 11
  • 3
0

Confirm your configuration with

<!-- GCM PERMISSIONS START -->
 <permission
        android:name="com.norton.mobile.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.norton.mobile.permission.MAPS_RECEIVE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <permission
        android:name="com.norton.mobile.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.norton.mobile.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- GCM PERMISSIONS END -->

<!-- GCM RECEIVER And SERVICE START -->

        <receiver
            android:name="com.google.android.gcm.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" />
                <action android:name="com.google.android.c2dm.intent.GCM_RECEIVED_ACTION" />

                <category android:name="com.norton.mobile" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.norton.mobile.GCMIntentService"
            android:enabled="true" />

        <!-- GCM RECEIVER And SERVICE END -->
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
  • My configuration looks perfectly fine. The only question is on the category of the receiver. How does it work on Os > 4.1 though the application package name does not match. – S.A.Norton Stanley Sep 13 '13 at 05:12