0
The app is crashing, stopping, when I get a push notification. This is happening on Android 8.0 (Oreo) or higher.
I see you’ve changed a policy, but I’m not getting it right in my code. I’m using the plugin phonegap-plugin-push in the version 1.9.1.
It gives the following error when receiving the push:
Unable do start receiver com.google.android.gms.gcm.Gcmreceiver: java.lang.Illegalstateexception: Not allowed to start service Intent { Act=com.google.android.c2dm.intent.RECEIVE...}
Man config.xml of Cordova is like this among other things:
<plugin name="phonegap-plugin-push" spec="1.9.2">
<variable name="SENDER_ID" value="#"/>
</plugin>
And mine Androidmanifest.xml generated at build time is like this:
<receiver android:exported="true" android:name="com.google.android.gms.gcm.GcmReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<service android:exported="false" android:name="com.adobe.phonegap.push.GCMIntentService">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service android:exported="false" android:name="com.adobe.phonegap.push.PushInstanceIDListenerService">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service android:exported="false" android:name="com.adobe.phonegap.push.RegistrationIntentService" />
Good do not understand of Ordova masss, from Android 8 have various restrictions to start services in the background, roughly so if the app is not in the foreground and is called startService() you will take an exception. I suggest taking a look at this restriction, the error seems to me to be related to this
– rnd_rss
That’s what it looks like. But I don’t know how to solve.
– Diego Souza
Good as it involves Ordova I will not be able to help, but I will leave two links from when I went through something similar and helped me, https://stackoverflow.com/questions/47110489/background-service-for-android-oreo and https://medium.com/exploring-android/exploring-background-Execution-Limits-on-android-Oreo-ab384762a66c
– rnd_rss
So, the problem is that it is a third party plugin. I don’t know where I should change the code. Maybe it can be solved with some variables in config.xml. I tried some I found, but none worked.
– Diego Souza