Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specific device not receiving Google Cloud Messaging notifications

I have an application where I'm implementing Google Cloud Messaging notifications, but in a specific device the messages don't arrive. This device has the minimum requirements to use GCM (Android version 2.2, Play Store installed and an Google Account logged). In the log I see that the device is receiving the registration id and sending to the back-office where I have a list of devices registered.

My question is: Do I need to make extra configurations to make the device receive these notifications?

Here is the manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="br.com.testegcm"
    android:versionCode="1"
    android:versionName="1" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="18" />

    <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="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="com.example.gcm.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

    <application
        android:name="TesteGCM"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >        

        <receiver
            android:name="br.com.testegcm.GcmBroadcastReceiver" 
            android:exported="true"
            android:enabled="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="br.com.testegcm" />
            </intent-filter>
        </receiver>

        <service android:name="br.com.testegcm.GcmIntentService" />

        <activity
            android:name="br.com.testegcm.Home"
            android:screenOrientation="portrait"
            android:label="@string/app_name"
            android:theme="@style/notitle" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
 </application>
</manifest>
like image 405
Danilo Silva Avatar asked Oct 11 '13 15:10

Danilo Silva


People also ask

How do I send FCM notification to one device?

For sending FCM notification payload you can use Firebase Cloud Messaging Tool in firebase console. And click on Send your first message. Then enter the Title and body field. If you wish to send it to a particular device then click on Send test message and enter the FCM registration token.

How do I send push notifications to multiple devices on Android?

Now to send Notifications to multiple devices of a user, you just need to send a notification to the user's Device Token group which, in turn, sends the push notification to all the devices in the group.


2 Answers

Change this :

<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />

to :

<permission android:name="br.com.testegcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="br.com.testegcm.permission.C2D_MESSAGE" />
like image 103
Eran Avatar answered Oct 15 '22 00:10

Eran


Add the same issue and i eventually i realized that i need to change in the manifest, the broadcast receiver package name from com.example.gcm to my package name :

 <!-- Push notifcations-->
        <receiver
                android:name=".BroadcastRecivers.GcmBroadcastReceiver"
                android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="com.example.gcm"/>
            </intent-filter>
        </receiver>

To

<!-- Push notifcations-->
        <receiver
                android:name=".BroadcastRecivers.GcmBroadcastReceiver"
                android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="MY PACKAGE NAME"/>
            </intent-filter>
        </receiver>
like image 21
shimi_tap Avatar answered Oct 14 '22 23:10

shimi_tap