A specific device that does not receive Google Cloud Messaging notifications

I have an application in which I implement Google Cloud Messaging notifications, but no messages arrive on a particular device. This device has the minimum requirements for using GCM (Android version 2.2, Play Store and Google account). In the log, I see that the device receives the registration ID and sends it to the back office, where I have a list of registered devices.

My question is: do I need to make additional settings to get devices to receive these notifications?

Here is the manifest

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.testegcm" android:versionCode="1" android:versionName="1" > <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="18" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <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" /> <permission android:name="com.example.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" /> <application android:name="TesteGCM" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <receiver android:name="br.com.testegcm.GcmBroadcastReceiver" android:exported="true" android:enabled="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="br.com.testegcm" /> </intent-filter> </receiver> <service android:name="br.com.testegcm.GcmIntentService" /> <activity android:name="br.com.testegcm.Home" android:screenOrientation="portrait" android:label="@string/app_name" android:theme="@style/notitle" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 
+6
source share
5 answers

Change this:

 <permission android:name="com.example.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" /> 

to:

 <permission android:name="br.com.testegcm.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="br.com.testegcm.permission.C2D_MESSAGE" /> 
+3
source

Add the same problem, and I finally realized that I needed to change the broadcast receiver package name from com.example.gcm in the manifest to my package name:

  <!-- Push notifcations--> <receiver android:name=".BroadcastRecivers.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.gcm"/> </intent-filter> </receiver> 

To

 <!-- Push notifcations--> <receiver android:name=".BroadcastRecivers.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND"> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE"/> <category android:name="MY PACKAGE NAME"/> </intent-filter> </receiver> 
+1
source

No , except for Android version 2.2, the installed Play Store application and the Google account registered in , no other configuration is required, now only two cases remain

 1) Either there is some ambiguity in your code. 2) or may be it is a device specific issue. 
0
source

I had the same problem. My code would work on nexus4 (Kitkat), but could not receive a notification from the appln server (via gcm-server). For versions smaller than 4.0.4, you must make sure that you have a google account installed on your device for gcm to work. I had a google account on my phone, but the mistake I made was that my Account and Sync settings on my galaxy tour were β€œOff”. When I turned it on and ran my code, I received a notification.

0
source

Check out the following solution. if still not working let me know. Add RECEIVE and REGISTRATION in two different intent filters

 <receiver android:name="<.GCM BroadcastReceiver Name>" // Name of your BroadcastReceiver, define in code. android:exported="true" android:permission="com.google.android.c2dm.permission.SEND" > <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="<Package Name>" /> </intent-filter> <intent-filter> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> <category android:name="<Package Name>" /> </intent-filter> </receiver> <service android:name="<.GCM IntentService Name>" /> // Name of your IntentService, define in code. <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 

Add RECEIVE and REGISTRATION Intent to two different intent filters, as shown above, otherwise it will not work for some devices (for example, HTC).

0
source

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


All Articles