简体   繁体   中英

Amazon SNS GCM Push for Android

I am trying to send push messages to my android device using Amazon SNS I was not able to create end point using the Android API key but I was able to create using the browser API key(which is confusing) Then when I try to send a push message, I get the error as "Permission Denial: receiving Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.example.androidpush] flg=0x10 (has extras) } to com.example.androidpush requires com.example.androidpush.permission.C2D_MESSAGE due to sender com.google.android.gsf (uid 10054)"

My Manifest file:

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

do you still have the problem ? hopefully your up and running. Anyways could be a reminder to close this question.

I believe the problem is with your receiver definition,

firstly, the .GcmBroadcastReceiver , is wrong , should be [com.google.android.gcm.GcmBroadcastReceiver]. This should resolve your problem however I think your registration will fail as you also need to add action [com.google.android.c2dm.intent.REGISTRATION] to your receiver.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM