startService issue on Oreo
GcmInstanceIdListenerService and RNNotificationsModule use startService method, but according to this it has to be replaced with startForegroundService and startForeground
After upgrading target SDK I have started getting crashes after notification is received if app is in background or closed state.
Any ideas for solution for this?
Error:
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.android.gms.gcm.GcmReceiver: java.lang.IllegalStateException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 pkg=com.package cmp=com.package/com.wix.reactnativenotifications.gcm.GcmMessageHandlerService (has extras) }: app is in background uid UidRecord{0000000 00000 RCVR idle change:idle|uncached procs:1 seq(0,0,0)}
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3194)
at android.app.ActivityThread.-wrap17(Unknown Source)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1672)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I tried replacing startService with mentioned methods, but that didn't solve it.
However upgrading com.google.android.gms:play-services-gcm from 10.0.2 to 11.2.2 in my app's app/build.gradle did solve the issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.