user1908805
user1908805

Reputation: 21

reason to "Permission Denial: receiving Intent "

I successfully made these c2dm implementations work on my app.

I have a problem when the c2dm messages are not received suddenly by the device. This time it gives me permission denial which I am confused about:

Permission Denial: receiving Intent {
act=com.google.android.c2dm.intent.REGISTRATION cat=[myapp.android] (has extras) } to myapp.android requires myapp.android.permission.C2D_MESSAGE due to sender com.google.android.location (uid 10037)

It happened to me the second time now, I can't just tell my users that they need to perform factory reset when they didn't receive any command. Has anyone here encounter similar issue? Any help or insights and causes would be much appreciated.

manifest.xml as requested


   <receiver
        android:name="myapp.EmBroadcastReceiver"
        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="myapp" />
        </intent-filter>
    </receiver>

...

<uses-permission android:name="myapp.android.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />

Upvotes: 2

Views: 4954

Answers (3)

AAP
AAP

Reputation: 1284

For me, it worked after I defined it as follows:

<permission android:name="mypkg.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
<uses-permission android:name="mypkg.permission.C2D_MESSAGE"/>

where mypkg = is my app's package

Upvotes: 6

Karsten
Karsten

Reputation: 310

I've run into the same problem, even when I had the permission defined in my manifest.

It seems to have something to do with protectionLevel="signature" and the definition of the permission becoming corrupted when the app is reinstalled with production vs debug keys.

What fixed it for me was temporarily setting protectionLevel="normal", then reinstalling the app, then changing back to "signature" and reinstalling again.

Upvotes: 0

Nikolay Elenkov
Nikolay Elenkov

Reputation: 52936

You also need to define the permission in your manifest like so, because it is not a system one, but one specific to your app:

<permission android:name="myapp.android.gms.permission.C2D_MESSAGE" />

In case you already have, it is probably a bug in a specific device or an older version of related Google libraries, etc. Not much you can do in that case.

Upvotes: 2

Related Questions