Reputation: 2369
In order to implement GCM correctly, a com.google.android.c2dm.SEND
permission should be specified for the receiver as per the official docs:
The receiver should require the com.google.android.c2dm.SEND permission, so that only the GCM Framework can send a message to it.
When I add that permission however, I get this error when a message is received.
W/GTalkService(25224): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.XXX.XXX] (has extras) }
followed by this error:
W/ActivityManager(283): Permission Denial: broadcasting Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.XXX.XXX] flg=0x10 (has extras) } from com.google.android.syncadapters.contacts requires com.google.android.c2dm.SEND due to receiver com.XXX.XXX/com.XXX.XXX.GcmBroadcastReceiver
If I remove that permission only, without changing anything else, the receiver works normally and I can process the message.
and here's the receiver definition in AndroidManifest.xml
<receiver
android:name="com.XXX.XXXX.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.XXX.XXX" />
</intent-filter>
</receiver>
I'm using the debug certificate during testing, in case that might be relevant.
Upvotes: 1
Views: 5123
Reputation: 1404
try this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<receiver
android:name="com.robustastudio.mateegy.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="com.robustastudio.mateegy" />
</intent-filter>
</receiver>
Upvotes: 1
Reputation: 1006799
Try com.google.android.c2dm.permission.SEND
instead of com.google.android.c2dm.SEND
, such as:
<receiver
android:name="GCMBroadcastReceiverCompat"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.commonsware.android.gcm.client"/>
</intent-filter>
</receiver>
(from this sample app)
Upvotes: 5