androidpush-notificationgoogle-cloud-messagingandroid-notificationsgcmlistenerservice

GCM Push Notification Not Revived


Below you can find the manifest file, is their anything wrong with configuration of GCM push notification classes ?

no notification is received at all on android devices but apple devices receive the notification

 package="ac.iec"
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

<permission
    android:name="ac.iec.permission.C2D_MESSAGE"
    android:protectionLevel="signature"/>

<uses-permission android:name="ac.iec.permission.C2D_MESSAGE"/>
    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
            <category android:name="ac.iec"/>
        </intent-filter>
    </receiver>
           <service
        android:name=".pushnotification.GCMIntentService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
        </intent-filter>
    </service>
    <service
        android:name=".pushnotification.MyInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID"/>
        </intent-filter>
    </service>

Solution

  • You have miss some user permisssion & reciver set like this way.

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    

    this permission to set

    <permission
        android:name="your package name.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    

    this user permission

    <uses-permission android:name="your package.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    

    this code set in application side.

     <!-- GCM Receiver -->
       <!-- this package name set your broadcast receiver class -->
        <receiver
    
            android:name="package name .GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
    
                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    
                <category android:name="main package name" />
            </intent-filter>
        </receiver>
    

    try this code in your manifest file. Thanks.