GcmBroadcastReceiver not starting on Android 4.0.3

I implemented GCM in my application following this official tutorial . But my users in Android 4.0.3 informed me that notifications do not work. I found out that onReceive from my GcmBroadcastReceiver extends BroadcastReceiver not running. Here is my manifest.

  <!-- GCM --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="android.permission.VIBRATE" /> <permission android:name="com.myapp.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.myapp.gcm.permission.C2D_MESSAGE" /> <application ... > <!-- GCM --> <receiver android:name="com.myapp.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.myapp" /> </intent-filter> </receiver> 

What am I doing wrong?

+4
source share
3 answers

Is your application the main name of the com.nyapp.gcm or com.myapp package?

In terms of manifest resolution, you use com.myapp.gcm, and in the recipient intent filter category, you use com.myapp.

In both places you should have the same package, which is the main package of your application.

+5
source

Your filter is missing the action "com.google.android.c2dm.intent.REGISTRATION", without which your application will not be able to get the registration ID. Add the following to your intent filter:

action android: name = "com.google.android.c2dm.intent.REGISTRATION"

0
source
 <!-- GCM --> <receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <!-- Receives the actual messages. --> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <!-- Receives the registration id. --> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="YOUR_APP_PACKAGE_NAME" /> </intent-filter> </receiver> 

Invalid permissions for your manifest file. Verifying BroadcastReceiver registration in manifest file

0
source

Source: https://habr.com/ru/post/1493086/


All Articles