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ł.