本文介绍了GCM广播接收机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直与Pubnub和GCM。虽然这个问题比较GCM / Android的特定比Pubnub。我有2应用程序 - 一个是我自己的,另一个是pubnub的例子

So I've been working with Pubnub and GCM. Although this question is more GCM/Android specific than Pubnub. I've 2 apps - one is my own the other is pubnub's example.

Pubnub清单的接收器标签:

Pubnub manifest's receiver tag:

<receiver
    android:name="com.pubnub.pubnubexample.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>

我的应用程序的接收器标签:

My app's receiver tag:

<receiver
    android:name="com.myapp.app.MyReceiver"
    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>

显然,pubnub示例应用程序的广播接收器被调用,但没有一个在我的。他们都有这些使用许可权

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

逸岸该矿甚至更多。

Infact mine has even more.

什么可能我是做错了,我自己的应用程序的接收器没有被称为GCM通知时通过它发送?我的期望是,因为它是一个广播类似的接收器的多个应用程序会接受他们?

What might I be doing wrong that my own app's receiver isn't being called by GCM when a notification is sent through it ? My expectation was that since it's a broadcast multiple apps with similar receivers would receive them ?

请注意:这是不是真的在我的工作,但测试,并试图理解这个概念是如何工作的要求

Note: This is not really a requirement in my work but testing and trying to understand how this concept works.

推荐答案

有一个问题,我可以看到的是,在你的Andr​​oidManifest文件的类别标签必须更新你的包名。

One issue I can see is that the category tag in your AndroidManifest file must be updated to your package name.

<category android:name="com.myapp.app." />

这篇关于GCM广播接收机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 02:14