除非SEND权限被删除GCM消息未收到 [英] GCM messages are not received unless SEND permission is removed

查看:282
本文介绍了除非SEND权限被删除GCM消息未收到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了正确实施GCM,一个 com.google.android.c2dm.SEND 许可应为接收器指定为每个的官方文档

In order to implement GCM correctly, a com.google.android.c2dm.SEND permission should be specified for the receiver as per the official docs:

的接收机应该要求com.google.android.c2dm.SEND许可,使得仅GCM框架可以发送消息给它。

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]广播意图回调:结果=已取消forIntent {行为= com.google.android.c2dm.intent.RECEIVE猫= [com.XXX.XXX](有临时演员)}

W/GTalkService(25224): [DataMsgMgr] broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.XXX.XXX] (has extras) }

其次是这个错误:

W / ActivityManager(283):权限拒绝:广播意向{行动= com.google.android.c2dm.intent.RECEIVE猫= [com.XXX.XXX] FLG = 0×10(有临时演员)}从com.google .android.syncadapters.contacts要求com.google.android.c2dm.SEND由于接收器com.XXX.XXX/com.XXX.XXX.GcmBroadcastReceiver

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.

和这里的在AndroidManifest.xml接收器定义

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.

推荐答案

尝试 com.google.android.c2dm.permission.SEND 而不是 com.google.android.c2dm.SEND ,如:

<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>

(从此示例应用

这篇关于除非SEND权限被删除GCM消息未收到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆