OneSignal with targetSdkVersion=26 getting error Background start not allowed: service Intent { cmp=***/com.onesignal.GcmIntentService(has extras) }

Hello everyone. 

I stared to preparing my app to newest Google Play’s target API level requirement , that says:

Google Play will require that new apps target at least Android 8.0 (API level 26) from August 1, 2018, and that app updates target Android 8.0 from November 1, 2018.

But unfortunately, when i changed value of  android:targetSdkVersion to “26” in my manifest.xml file i cannot recieve any push notifications when my app is closed/running on background.

When app is active everything works perfectly (alert is showing with correct data) so i know that notifications works in some limited way but they are delivered correctly. In conclusion this is not problem with OneSignal portal, but with OneSignal Plugin. 

Main problem is when app is closed - when notification is delivered nothing happens, there is no sound/vibrate/notification. I got logcat from device (Huawei Mate 10 pro, Android 8.0) generated at time of push delivery: 

06-12 15:10:36.895 1195 1823 W ActivityManager: Background start not allowed: service Intent { cmp=my\_package\_name/com.onesignal.GcmIntentService (has extras) } to my\_package\_name/com.onesignal.GcmIntentService from pid=7731 uid=10432 pkg=my\_package\_name 06-12 15:10:36.896 7731 7731 D AndroidRuntime: Shutting down VM --------- beginning of crash 06-12 15:10:36.897 7731 7731 E AndroidRuntime: FATAL EXCEPTION: main 06-12 15:10:36.897 7731 7731 E AndroidRuntime: Process: my\_package\_name, PID: 7731 06-12 15:10:36.897 7731 7731 E AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.onesignal.GcmBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=my\_package\_name/com.onesignal.GcmIntentService (has extras) }: app is in background uid UidRecord{6197f04 u0a432 RCVR idle procs:1 seq(0,0,0)} 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3705) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ActivityThread.-wrap18(Unknown Source:0) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1979) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:108) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.os.Looper.loop(Looper.java:166) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7425) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=my\_package\_name/com.onesignal.GcmIntentService (has extras) }: app is in background uid UidRecord{6197f04 u0a432 RCVR idle procs:1 seq(0,0,0)} 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1701) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ContextImpl.startService(ContextImpl.java:1657) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.content.ContextWrapper.startService(ContextWrapper.java:644) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.content.ContextWrapper.startService(ContextWrapper.java:644) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService(SourceFile:91) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(SourceFile:76) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at com.onesignal.GcmBroadcastReceiver.onReceive(SourceFile:59) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: at android.app.ActivityThread.handleReceiver(ActivityThread.java:3695) 06-12 15:10:36.897 7731 7731 E AndroidRuntime: ... 8 more 06-12 15:10:36.897 1195 1823 V BroadcastQueue: Finished with ordered broadcast BroadcastRecord{c72b8ca u0 com.google.android.c2dm.intent.RECEIVE} 06-12 15:10:36.898 3082 3082 W GCM : broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=my\_package\_name (has extras) } 06-12 15:10:36.900 1195 1823 I ActivityManager: Killing 30060:com.instagram.android/u0a109 (adj 906): empty #33 06-12 15:10:36.909 1195 3422 E ReportTools: This is not beta user build

What i can do? I’ve downloaded latest OneSignal Plugin…

Moreover when  android:targetSdkVersion  is set to   “25” everything works perfectly, but this solution is only temporary.

Whats more I’ve build my app using Corona Simulator then decoded output app with apktool and i found that the latest daily version of Corona (2018.3315) is still using  android:targetSdkVersion=“25”. 

Last thing: I’ve tested app that was build with parameter  android:targetSdkVersion set to  “26”  on device with Android 7.0 (Samsung s6) and with my surprise, notifications works correctly when app is closed. So problem is only with Android 8.0.

Any help will be appreciated!  

Best regards,

Paweł.

Corona is still working on target version 26. I am actually surprised you got this far. They will notify us when it is ready for testing. Ignore all this if you are in some internal testing group that I am not aware of.

You cannot just select an SDK target with Corona. As @agramonte states, we are working on adding support for SDK version 26, but for now you should not be running apktool and making manual changes to your project.

Rob

OK i get it, so when you will add support to target version 26, then you will also fix OneSingal Plugin to support Android 8.0? Good to hear that you working on adding that support! 

@Rob: I know i shouldn’t make any manual changes in created .apk and i don’t do it. I was just curious what android:targetVersion is in .apk build by latest Corona Daily Build. My native project is working on old Corona version 2017.3079 so i wanted to check if newest daily build support version 26 already.

OneSignal maintains their own plugin. It will be up to them to update it after we enable SDK version 26.

Rob

@Rob. Good to know. Thank You very much for answering! So for now my topic is resolved. 

Will the warning from Google Play - that the App has to support SDK 28 in August - automatically disappear when I build with the new version of Corona SDK (when it appears) ?

Once we release support for that API level, if you rebuild your app, that warning should disappear.

Rob

We have encountered this and can’t see a way around it - has this bug seen any movement yet?

We have reached out to OneSignal to see if we can get an update. I’ll update here when I hear something. You probably should reach out to OneSignal as well.

Rob

Hi Rob, I have the same error of first post with onesignal plugin. The app crash if it’s on background and when receive a push from onesignal.

AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.onesignal.GcmBroadcastReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { cmp=xxx/com.onesignal.GcmIntentService (has extras) }: app is in background uid UidRecord{3ec248 u0a370 RCVR idle procs:1 seq(0,0,0)}

I have the latest version of corona sdk (daily build). The plugin is updated?

The OneSignal plugin is provided by OneSignal. It does not appear the plugin has been updated since January. We’ve reached out to them, but haven’t heard anything. Perhaps it would be more impactful if more community developers reached out to them to encourage them to update the plugin.

Rob

This is a serious disappointment. oneSignal’s Corona SDK plugin is causing a huge number of crashes and remains the most significant issue in our published app.

java.lang.IllegalStateException

com.onesignal.GcmBroadcastReceiver.processOrderBroadcast

Samsung Galaxy S8 (dreamlte), Android 8.0 (ONE OF MANY)

java.lang.RuntimeException :

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3397)

at android.app.ActivityThread.-wrap18 (Unknown Source)

at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1780)

at android.os.Handler.dispatchMessage (Handler.java:105)

at android.os.Looper.loop (Looper.java:164)

at android.app.ActivityThread.main (ActivityThread.java:6938)

at java.lang.reflect.Method.invoke (Native Method)

at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)

at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

Caused by: java.lang.IllegalStateException :

at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1538)

at android.app.ContextImpl.startService (ContextImpl.java:1484)

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

at android.content.ContextWrapper.startService (ContextWrapper.java:663)

at android.support.v4.content.WakefulBroadcastReceiver.startWakefulService (WakefulBroadcastReceiver.java:99)

at com.onesignal.GcmBroadcastReceiver.processOrderBroadcast (GcmBroadcastReceiver.java:76)

at com.onesignal.GcmBroadcastReceiver.onReceive (GcmBroadcastReceiver.java:59)

at android.app.ActivityThread.handleReceiver (ActivityThread.java:3390)

I just reached out to oneSignal via their online chat. The response I received was “back tomorrow”

I believe Corona’s 2018 update to its Notifications Plugin will provide the best alternative to avoid this problem: https://marketplace.coronalabs.com/corona-plugins/notifications

I’m working to implement it now.

@Rob, @CoronaLabs, 1) does the latest CoronaLabs notifications plugin work on all Android version 5+? We have enjoyed using the oneSignal API to send notifications to specific devices? 2) Do you know if the GCM service can be used via an API to do the same thing? Of course I can research this, but I was just curious if you or anyone at CoronaLabs knew the answer to this. Thanks for all your help!

There are two versions of the notification plugin. The older version does Google’s GCM messaging. The newer version does Firebase messaging. Both should work on all supported versions of Android as long as Google still supports GCM on the platforms.

I’ve not used oneSignal, but basically when you use a service like Urban Airship, or Pushwoosh, what you’re getting is a web interface to send out push notification to your customers. They allow you to segment your audience and support other features. In other words, it’s what your customer would do to send the actual message.  I believe oneSignal provides this service.  iOS APNS and Google’s push services (GCM and FCM) job is to take messages that come in via there API which broadcasts the messages to the devices.

Now FCM may have a web interface to handle sending out messages. I’ve never used it.

We don’t have any direct API’s to broadcast messages through FCM, but I think they have a REST API for doing it.

Rob

No news from onesignal. I have written via chat online but no answers… Manual settings of notifications it’s too long for me. Do you have another service integrated in corona sdk?

https://www.pushwoosh.com/docs/corona-sdk

It’s active?

 @fixr, I’ve implemented pushwoosh before, then oneSignal - in both cases, I’ve had problems after they were initially working. My team is working to resolve the issues of Scott’s Firebase plugin (for analytics) and Corona’s Notifications plugin (recently updated) working together. We are hopeful to have the solution to this shortly, as our current LIVE app is crashing more than 1000 times a month (thanks to OneSignals failures) and publish a sample app for all. Stay tuned.