我正在尝试使用Amazon SNS将推送消息发送到我的Android设备 我无法使用Android API密钥创建终点,但我能够使用浏览器API密钥创建(这令人困惑) 然后当我尝试发送推送消息时,我得到错误为“权限拒绝:接收意图{act = com.google.android.c2dm.intent.RECEIVE cat = [com.example.androidpush] flg = 0x10(有额外内容) )} to com.example.androidpush需要com.example.androidpush.permission.C2D_MESSAGE,因为发件人com.google.android.gsf(uid 10054)“
我的清单文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidpush"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.example.androidpush.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.androidpush.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name=".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.androidpush" />
</intent-filter>
</receiver>
<service android:name=".GcmIntentService" />
<permission android:name="com.example.androidpush.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
答案 0 :(得分:1)
我认为问题在于您的接收器定义,
首先,.GcmBroadcastReceiver是错的,应该是[com.google.android.gcm.GcmBroadcastReceiver]。这应该可以解决您的问题,但我认为您的注册将失败,因为您还需要向接收方添加操作[com.google.android.c2dm.intent.REGISTRATION]。
<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.example.androidpush" />
</intent-filter>
</receiver>