Android操作系统上的GCM推送接收类别名称<;4.1
我已为我的应用程序启用推送功能,我的清单如下所示: 包名称:Android操作系统上的GCM推送接收类别名称<;4.1,android,google-cloud-messaging,Android,Google Cloud Messaging,我已为我的应用程序启用推送功能,我的清单如下所示: 包名称: <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.norton.mobile" android:versionCode="1" android:versionName="1.0" > 我的接受者如下: <receiver android:name="com.pravaa.mobile
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.norton.mobile"
android:versionCode="1"
android:versionName="1.0" >
我的接受者如下:
<receiver
android:name="com.pravaa.mobile.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.stanley.mobile" />
</intent-filter>
</receiver>
通过以上配置,我能够在OS>4.1的任何设备上成功接收通知,但在OS<4.1的设备上无法接收通知。在将接收器类别配置修改为***
时,即使在操作系统<4.1的设备上,我也能够成功地接收通知。我确实理解文档中说的“com.google.android.c2dm.intent.RECEIVE的接收器,类别设置为applicationPackage。”但是它如何适用于OS>4.1的设备,尽管类别与applicationPackage不匹配。
有人知道这背后的原因吗?提前感谢。使用确认您的配置
<!-- GCM PERMISSIONS START -->
<permission
android:name="com.norton.mobile.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.norton.mobile.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<permission
android:name="com.norton.mobile.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.norton.mobile.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- GCM PERMISSIONS END -->
<!-- GCM RECEIVER And SERVICE START -->
<receiver
android:name="com.google.android.gcm.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" />
<action android:name="com.google.android.c2dm.intent.GCM_RECEIVED_ACTION" />
<category android:name="com.norton.mobile" />
</intent-filter>
</receiver>
<service
android:name="com.norton.mobile.GCMIntentService"
android:enabled="true" />
<!-- GCM RECEIVER And SERVICE END -->
使用确认您的配置
<!-- GCM PERMISSIONS START -->
<permission
android:name="com.norton.mobile.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.norton.mobile.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<permission
android:name="com.norton.mobile.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.norton.mobile.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- GCM PERMISSIONS END -->
<!-- GCM RECEIVER And SERVICE START -->
<receiver
android:name="com.google.android.gcm.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" />
<action android:name="com.google.android.c2dm.intent.GCM_RECEIVED_ACTION" />
<category android:name="com.norton.mobile" />
</intent-filter>
</receiver>
<service
android:name="com.norton.mobile.GCMIntentService"
android:enabled="true" />
<!-- GCM RECEIVER And SERVICE END -->
也许你写了一个错误的类别名称,它起作用了,因为在OS 4.1以上不需要类别名称 " 请注意,类别标记中的android:name必须替换为应用程序的包名(针对MinsdkVersion16及更高版本的应用程序不需要类别标记)
“也许你写了一个错误的类别名称,它起作用了,因为在OS 4.1以上不需要类别名称 " 请注意,类别标记中的android:name必须替换为应用程序的包名(针对MinsdkVersion16及更高版本的应用程序不需要类别标记)
“你以前吃过什么?上面显示的示例包含您最近添加的
。我最初的类别是在Os<4.1的设备上不起作用的,它只有在更改它以匹配软件包名称后才开始起作用。据我所知是真的,即使我同意它。我只想知道它在OS>4.1上是如何工作的。该类别是否未在OS>4.1上验证?您以前有过什么?上面显示的示例包含您最近添加的
。我最初的类别是在Os<4.1的设备上不起作用的,它只有在更改它以匹配软件包名称后才开始起作用。据我所知是真的,即使我同意它。我只想知道它在OS>4.1上是如何工作的。该类别是否未在OS>4.1上验证?我的配置看起来非常好。唯一的问题是关于接收者的类别。虽然应用程序包名称不匹配,但它如何在Os>4.1上工作。我的配置看起来非常好。唯一的问题是关于接收者的类别。虽然应用程序包名称不匹配,但它在Os>4.1上如何工作。