推送通知接收器 android(清单?)
Posted
技术标签:
【中文标题】推送通知接收器 android(清单?)【英文标题】:Push Notification receiver android( manifest?) 【发布时间】:2013-06-27 13:34:31 【问题描述】:我正在使用谷歌推送通知,到目前为止它运行良好, 目前推送通知不起作用,因为 onRegistered 从未启动。我认为问题出在清单中(因为问题是从未调用过接收器)但我不确定
这是我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.name.name"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE" android:protectionLevel="normal" />
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.name.name.Disclaimer"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.name.name.Pago"
>
</activity>
<activity android:name="com.name.name.MainActivity" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.NoMiembros" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.ZonaMiembros" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.PlayvideofromserverActivity" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.GoPromo" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.PantallaCarga" android:screenOrientation="portrait"></activity>
<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" />
<category android:name="com.name.name" />
</intent-filter>
</receiver>
<receiver android:name=".SMSHandler$MessageReceiver" android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>
【问题讨论】:
是您应用程序默认包中的GCMIntentService
..?? (验证清单标签:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.my.package" android:versionCode="1" android:versionName="1.0" >
,GCMIntentService
应该在那个包中
【参考方案1】:
尝试改变这个:
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE"
android:protectionLevel="normal" />
到这里:
<permission android:name="com.name.name.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE" />
【讨论】:
【参考方案2】:我不确定交叉在哪里停止,但我仍在使用 C2DM 而不是 GCM,并且我将我的消息和注册接收器声明为本地类,而不是像你一样指向 google 类。
<receiver
android:name=".utils.C2DMRegistrationReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" >
</action>
<category android:name="package.name.here" />
</intent-filter>
</receiver>
<receiver
android:name=".utils.C2DMMessageReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" >
</action>
<category android:name="package.name.here" />
</intent-filter>
</receiver>
【讨论】:
以上是关于推送通知接收器 android(清单?)的主要内容,如果未能解决你的问题,请参考以下文章