Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

OneSignal with targetSdkVersion=26 getting error Background start not allowed: service Intent { cmp=***/com.onesignal.GcmIntentService(has extras) }
Started by p.kanarek Jun 12 2018 07:56 AM

70 replies to this topic
onesignal gcmintentservice targetsdkversion push
[TOPIC CONTROLS]
Page 1 of 3 1 2 3
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

p.kanarek

[GLOBAL: userInfoPane.html]
p.kanarek
  • Observer

  • 19 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 824 posts
  • Corona SDK

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.



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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



[TOPIC: post.html]
#4

p.kanarek

[GLOBAL: userInfoPane.html]
p.kanarek
  • Observer

  • 19 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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

 

Rob



[TOPIC: post.html]
#6

p.kanarek

[GLOBAL: userInfoPane.html]
p.kanarek
  • Observer

  • 19 posts
  • Corona SDK

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



[TOPIC: post.html]
#7

bbk

[GLOBAL: userInfoPane.html]
bbk
  • Enthusiast

  • 39 posts
  • Corona SDK

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) ?



[TOPIC: post.html]
#8

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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

 

Rob



[TOPIC: post.html]
#9

MBD

[GLOBAL: userInfoPane.html]
MBD
  • Contributor

  • 384 posts
  • Corona SDK

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



[TOPIC: post.html]
#10

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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



[TOPIC: post.html]
#11

fixr

[GLOBAL: userInfoPane.html]
fixr
  • Observer

  • 18 posts
  • Corona SDK

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?



[TOPIC: post.html]
#12

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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



[TOPIC: post.html]
#13

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

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)


[TOPIC: post.html]
#14

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

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



[TOPIC: post.html]
#15

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

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.



[TOPIC: post.html]
#16

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

@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!



[TOPIC: post.html]
#17

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

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



[TOPIC: post.html]
#18

fixr

[GLOBAL: userInfoPane.html]
fixr
  • Observer

  • 18 posts
  • Corona SDK

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

 

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?



[TOPIC: post.html]
#19

fixr

[GLOBAL: userInfoPane.html]
fixr
  • Observer

  • 18 posts
  • Corona SDK

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

 

It's active?



[TOPIC: post.html]
#20

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 520 posts
  • Corona SDK

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



[TOPIC: post.html]
#21

fixr

[GLOBAL: userInfoPane.html]
fixr
  • Observer

  • 18 posts
  • Corona SDK

@troylyndon Thank you! I've also written a private message to https://forums.coronalabs.com/user/496106-josh-onesignal/

that it's a member of onesignal



[TOPIC: post.html]
#22

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,865 posts
  • Corona Staff

You might also want to look at PlayFab and/or GameSparks. I believe they both support sending push notifications. 

 

What might also be helpful is to understand how you're using push notifications.

 

One common use, for instance, is a news organization would use a service like PushWoosh or Urban Airship to log in, write the text for a push, provide a URL to a story and blast that out to all app users. The push would arrive at the app and if interacted with, bring the app to the foreground and if reasonable, deep link to the article.

 

Turn-based games on the other hand, will send a message to the game server indicating that the player has completed the turn and the game server will send a targeted push to the other player. If the player is active, usually the game server will transmit the message. If the app is in the background a push notification would let the user interact with it and bring the game to the foreground and process the turn.

 

I'm sure there are other uses which is why I think it would be helpful to know how you plan to use push in your apps?



[TOPIC: post.html]
#23

adrianjgomez

[GLOBAL: userInfoPane.html]
adrianjgomez
  • Observer

  • 3 posts
  • Corona SDK

Gamespark does and here is my cloud code for OneSignal:

function SendNewNotification() {

  var jsonBody = {

    app_id: "<OneSignalAppId>",

    filters: [

  	  {"field": "tag", "key": "gsUserId", "relation": "=", "value": <PlayerId>}

    ],

    contents: {en:<textForEngish>, es:<Optional: other language text in this case Spanish>},

  };

  var response = Spark.getHttp("https://onesignal.com/api/v1/notifications").setHeaders({

    "Content-Type": "application/json;charset=utf-8",

    "Authorization": "Basic <service api key from OneSignal>"

  }).postJson(jsonBody);
  

  return response;

}

var response = SendNewNotification().getResponseJson();


[TOPIC: post.html]
#24

adrianjgomez

[GLOBAL: userInfoPane.html]
adrianjgomez
  • Observer

  • 3 posts
  • Corona SDK

Also, I believe the easiest approach would be to keep using OneSignal but use their REST api instead of the SDK until they fix the issue. At least that is what I plan to do with my latest version. I'll post the code shortly. Just seems like an easier path for me rather than working on a new plugin.



[TOPIC: post.html]
#25

josh_OneSignal

[GLOBAL: userInfoPane.html]
josh_OneSignal
  • Enthusiast

  • 55 posts
  • Corona SDK

Sorry for the delay on this, we are looking into updating the OneSignal plugin in the coming weeks for Android Oreo 8 compatibility. This will fix the `IllegalStateException` crash that are showing up.

 

In the mean time there are 2 work arounds that can be done;

 

1. Use Corona SDK version 3325 or older. This sets targetSdkVersion to 25 to work around this issue.  This only works if you are updating existing apps already released on the Google Play Store. The Google Play Console won't let you create new apps with targetSdkVersion lower than 26.

 

2. Use the latest OneSignal Android Native SDK with Corona Native; This doesn't come with any Lua bindings so you will need to initialize the SDK and use it's methods through Java or Kotlin. However this native SDK has already been updated to support Android Oreo and works with Android Pie as well. See the OneSignal Android SDK Setup to add this to your native project.

 

3. Switch to using plugin.notifications.v2 and OneSignal's REST API based methods. Corona developer @agramonte has a nice functional library you can use now. https://forums.coronalabs.com/topic/73652-onesignal-android/


  • fixr likes this


[topic_controls]
Page 1 of 3 1 2 3
 
[/topic_controls]

Also tagged with one or more of these keywords: onesignal, gcmintentservice, targetsdkversion, push