App does not receive GCM messages after reboot on Android 5.0 - android

I use react-native-gcm-android and react-native-system-notification packages to manage GCM notifications (Android), everything works fine on Android 4.x but on 5.0 (ASUS_Z00AD) after reboot GCM messages not appear, log shows me
W/BroadcastQueue( 639): Reject to launch app com.Sgoomys.Main/10246 for broadcast: App Op 48
W/GCM-DMM ( 1824): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.Sgoomys.Main (has extras) }
In AndroidManifest.xml all the settings are made according the packages documentation:
<permission
android:name="com.Sgoomys.Main.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.Sgoomys.Main.permission.C2D_MESSAGE" />
...
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
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="com.Sgoomys.Main" />
</intent-filter>
</receiver>
<service android:name="com.oney.gcm.GcmRegistrationService"/>
<service android:name="com.oney.gcm.BackgroundService"></service>
<service
android:name="io.neson.react.notification.GCMNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<receiver
android:exported="false"
android:name="com.oney.gcm.GcmBroadcastReceiver">
<intent-filter>
<action android:name="com.oney.gcm.GCMReceiveNotification" />
</intent-filter>
</receiver>
Google Play Services library is com.google.android.gms:play-services-gcm:8.4.0

Finally I solved the puzzle...
Application doesn't start at boot-up because it was blocked by Asus utility "Auto-start manager" - all recently installed apps are blocked by default.
So now I will add a check for com.asus.mobilemanager package with alert and button to start this utility and unblock autorun, but I think the correct way will be detect all possible blocking software and inform user about it.

Related

Android 10 BOOT_COMPLETED Broadcast not received to application

I have to run the service using BOOT_COMPLETED Broadcast but while the Android 10 device is booting I get the following warning.
system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.LOCKED_BOOT_COMPLETED flg=0x400010 } to com.rahul.http/.BootReceiver
Mainifest:
<service
android:name=".HttpUpdateService"
android:enabled="true"
android:directBootAware="true"
android:exported="true">
</service>
<receiver android:name=".BootReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:exported="true"
>
<intent-filter android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>
I have also added permission for receiving boot_complete broadcast.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
I don't have any activity in my application.
try to add add android:directBootAware to your <receiver, as in DOCs
Try adding following attribute in your application tag in Manifest :
android:directBootAware="true"
When you received an intent on Broadcast receiver you have to add the check if your application target below the Android O version. Something like this:
if app build version greater than android O than you must called startForegroundService method with provided intent. otherwise you just called the method startService with provided intent.

EnhancedIntentService warning On Incoming Notifications

I have been getting two errors in my log once a notification is received
EnhancedIntentService: Service took too long to process intent: com.google.android.c2dm.intent.RECEIVE App may get closed
EnhancedIntentService: binding to the service failed
There is NOTHING on Google of either of these messages or even EnhancedIntentService.
Relevant code:
<service
android:name="---.GcmMCIntentService"
android:exported="false" >
<intent-filter android:priority="10">
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="---.GCMInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service android:name="---.GCMRegIntentService"
android:exported="false" >
<intent-filter android:priority="5">
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
This is on a 8.0 emulator. Play Services 11.4.2
Let me know if I can show any other code. I just find it curious there is nothing on these error messages at all on S.O. or Google.

GCM error on receive: Failed to resolve target intent service, skipping classname enforcement

I followed the instructions here to set up a client GCM app: https://developers.google.com/cloud-messaging/android/client
I opted to use the standard GCM rather than the new Firebase Cloud Messaging, for now.
My app server is a node.js instance using node-gcm to send push notifications.
My app receives the notifications successfully, however prints out the following errors:
E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
Here are the relevant bits of my AndroidManifest.xml:
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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.myapp" />
</intent-filter>
</receiver>
<service
android:name="com.example.myapp.gcm.GcmListener"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.myapp.gcm.InstanceIDListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service android:name="com.example.myapp.gcm.RegistrationIntentService"
android:exported="false" />
My project has all of the above classes (minus GcmReceiver which is provided by Google).
GcmReceiver extends GcmListenerService
InstanceIDListener extends InstanceIDListenerService
RegistrationIntentService extends IntentService
Am I missing anything that might be causing this error? Does the error actually affect anything?

Failed to resolve Intent Service Android

I am getting following error when trying to configure Push Notification:
06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
06-07 01:05:59.735 18708-18708/com.ebr.apps.ebr.development E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
I have different flavors in gradle:
My code package name is : com.ebr.apps.ebr
My product flavor package is: com.ebr.apps.ebr.development
I have placed google-services.json in app/src/development
Manifest:
<permission
android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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="${applicationId}" />
</intent-filter>
</receiver>
<service
android:name=".GCM.PushNotificationService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
I have looked at many example but still getting this error.
I found the solution, the problem was that Instabug GCMListener was conflicting with my GCMListener. I set the priority of my gcm listener and it started working.
<service
android:name=".GCM.PushNotificationService"
android:exported="false">
<intent-filter android:priority="10000">
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
</intent-filter>
</service>
If your coming from a search engine: you might have as well run into this bug, which affects also the current version com.google.android.gms:play-services-gcm:9.8.0
https://github.com/firebase/quickstart-android/issues/72
It was not yet possible to reproduce the bug and it is not fully understood how the situation can happen but you might be interested in following the thread.

Cannot register to GCM for push notifications on Android 5 and 5.1

I am developing an AIR application and I implemented push notifications for Android using GCM. The service works perfectly on all devices except those having Android 5.0 or 5.1 OS. The application simply doesn't receive a registration id from GCM.
Neither PERMISSION_GIVEN_WITH_TOKEN_EVENT nor PERMISSION_REFUSED_EVENT are never raised. I am not getting any response from GCM.
Did anybody have this problem? Could you please help me?
I am using Air Native Extension for Push Notifications from Freshplanet github.com/freshplanet/ANE-Push-Notification
So this is my code:
PushNotification.getInstance().registerForPushNotification(GOOGLE_PROJECT_ID); PushNotification.getInstance().addEventListener(PushNotificationEvent.PERMISSION_REFUSED_EVENT, onPushNotificationTokenFailed);
function onPushNotificationToken(event:PushNotificationEvent):void {
trace("My push token is: " + event.token);
}
function onPushNotificationTokenFailed(event:PushNotificationEvent):void
{
trace(event.errorCode);
trace(event.errorMessage);
trace();
}
And my manifest file (partial):
<permission android:name="MY_APP_ID.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="MY_APP_ID.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application>
<activity android:name="com.freshplanet.nativeExtensions.NotificationActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<receiver android:name="com.freshplanet.nativeExtensions.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="MY_APP_ID" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="MY_APP_ID" />
</intent-filter>
</receiver>
<service android:name="com.freshplanet.nativeExtensions.LocalNotificationService"/>
<receiver android:name="com.freshplanet.nativeExtensions.LocalBroadcastReceiver" android:process=":remote">
</receiver>
Thanks in advance!

Categories

Resources