OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
604 stars 368 forks source link

NotificationOpenedReceiver not opening after clearing app is some devices #601

Closed rameshvoltella closed 6 years ago

rameshvoltella commented 6 years ago

NotificationOpenedReceiver not calling in some devices

i will explain the way to produce

let the app is open and send a push, we will receive the notification, After that clear the application by swiping(our usual way to clear the app), now if i click the received notification nothing is happening , the notification is been removed but no action is taken place.Mi a1 , Motorola, devices its working fine, but device like Gionee A1 (Android version 7.0)and ONEPLUS A5000 (Android version 8.1.0 ).Notification is not opening

when i debug i was able to get this log

07-26 20:37:54.902 1071-648/? V/ActivityManager: Broadcast: Intent { flg=0x10 cmp=com.my.app/com.onesignal.NotificationOpenedReceiver (has extras) } ordered=false userid=0 callerApp=null 07-26 20:37:54.905 1071-1100/? W/BroadcastQueue: Unable to launch app com.my.app/10156 for broadcast Intent { flg=0x10 cmp=com.my.app/com.onesignal.NotificationOpenedReceiver (has extras) }: process is bad.

i dont know how many more devices having this issue,If you want more info am ready to give

jkasten2 commented 6 years ago

@rameshvoltella The process is bad error normally happens when Android ignores intents if the app crashed a few times. Can you check your logcat before this error to see if your app is crashing?

rameshvoltella commented 6 years ago

No app doesn't crash, this happened only when i clear my app when i already have a notification, after that when i click notification, i saw this on the log.

Edit.....

I have confirmed there is no crash happening

rameshvoltella commented 6 years ago

@jkasten2 any suggestions?

rameshvoltella commented 6 years ago

@jkasten2 i have noticed that the notification that does not open is appearing again if i launch the app, Why is that is that some thing you guys handle any missing notification? i wnt to mention that it happening in one plus and gionee as i tested, i can tell how i produce it. Gionee A1 (Android version 7.0) 1)Open the app 2)Wait till a notification received. 3)Clear the app (like we always swipe),Remember, don't clear the notification 4)As now our app is not in memory click on the notification. 5)Noting will happen

But if i open the app again notification is coming back, The above log is only what i get.

Also Some user complain the havent receving notification, i have know some user i send notification seperatly to those users, the console say it received but i debugged no notification came.

Please mention what can be gone wrong.

jkasten2 commented 6 years ago

@rameshvoltella Do you have the Android Studio debugger attached to your app when you swipe your app away in step 3? If so this can freeze the so I recommend testing your steps without the device connected to your system to be sure. Let us know if you can reproduce the issue this way still.

rameshvoltella commented 6 years ago

@jkasten2 i have reproduced this issue first without connecting to debugger, in my office 3 people have oneplus, all of them having this issue, and I found this isse in gionee A1 also, i debugging on A1 only, but i myself produce this issue oneplus without connecting debugger, Also it has noted that if app is not using or not opened in 2 or 3 days, and if we send a notification its not receving also.

jkasten2 commented 6 years ago

@rameshvoltella The issue you are describing seems like the OnePlus devices are putting your app into a battery optimize mode. You should be able to go to do the following on the device to prevent this. Go to Settings > Battery > Battery Optimization > Application > Don't Optimize https://documentation.onesignal.com/docs/notifications-show-successful-but-are-not-being-shown#section-the-app-is-force-stopped

There are reports of an issue like this for other apps as well from users. https://forums.oneplus.com/threads/battery-optimization-keeps-getting-reset-for-whatsapp.770616/

Lastly I recommend making sure you have the latest Android update installed on your test devices to make sure you are testing the most common case.

For your Gionee, they most likely are doing something similar as OnePlus

rameshvoltella commented 6 years ago

@jkasten2 we cant do anything on this issue?one of my competitive app does not have this issue. I check battery optimization there option is same as mine. I closed there app and wait until one day but it received notification, They are not using onesignal usual fcm only, Also they are not default whitelist app as whatsapp or facebook, any idea how they are achieve this solution (in oneplus)

jkasten2 commented 6 years ago

@rameshvoltella The only other reason I could see why is if you have some other background process that is crashing your app after some time. The issue might be related to Android version rather than device manufacture. I would look from your logcat carefully to see if you can find any crashes and / or setup something like crashlytics to log any possible background crashes or ANRs

rameshvoltella commented 6 years ago

@jkasten2 no crash is happening and am sure about that.i had made a separate project with only onesignal implemented and i given that app to the oneplus device. After installing push has received in the app. After that we close the app. After one day i send one more push, but it say it send via console but I didn't received it

jkasten2 commented 6 years ago

@rameshvoltella After sending the notification can you check the logcat on the device? Check for anything with FCM, GCM, or your package name in it.

rameshvoltella commented 6 years ago

@jkasten2 will check

rameshvoltella commented 6 years ago

@jkasten2 any suggestion

rameshvoltella commented 6 years ago

@jkasten2 will solution 2 in the link https://stackoverflow.com/questions/28874973/android-repeating-alarm-calls-service-but-eventually-gets-process-is-bad-error help to fix the issue #601 and also i just wanna confirm

process is bad

is occurring because of the crash of one signal service in background because my app have no background functions, only work when app is open.

jkasten2 commented 6 years ago

@rameshvoltella If you app is on the Play Store can you check the Google Play Console for any crashes that included OneSignal? Or any crashes in your logcat on your devices?

process is bad happens from repeated crashes of your app in the background. It would cause any background intent to no longer start your app including FCM intents for push notifications.

rameshvoltella commented 6 years ago

@jkasten2 Yesterday i tried one test i removed all the gcm and onesignal stuff from my app and implemented the FCM. When i try push on app is not killed it was working but when i swipe and clear the app it show the following log at the time of receiving notification.

09-25 16:47:29.591 3422-3422/? W/GCM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=in.my.pack (has extras) }

What does this means is it any this related to this issue? , by the way i tested on oneplus device

jkasten2 commented 6 years ago

@rameshvoltella That error means your app has been "Force Stopped" and the GCM Intent could not start your app to process the payload do to this. There isn't anything your app can do to get out of this state. No other intents will start your app until the user opens your app again.

If notifications are core to your app the best you can do is try to detect these devices and prompt users to disable battery optimizations noted in this guide. https://documentation.onesignal.com/docs/notifications-show-successful-but-are-not-being-shown#section-the-app-is-force-stopped

The Forced Stopped state either after some time or after the app is swiped away isn't something ASOP Android does. The issue with specific devices is due to manufactures customizing Android and putting apps into this state based on their own custom rules.

rameshvoltella commented 6 years ago

@jkasten2 why this issue closed? is it because it wont fix?

jkasten2 commented 6 years ago

@rameshvoltella You noted you are seeing the same issue with pushes not working without OneSignal and using FCM on your oneplus device. Since this is an issue with the device / ROM there isn't anything OneSignal or Firebase can do to fix this.

In additional to making a note about this to users in your app I noted above I also recommend contacting OnePlus about the issue. But I don't see anything else that can be done.

jkasten2 commented 6 years ago

@rameshvoltella Just a quick update on the GCM warning with CANCELLED in it you posted before. Since you seen flg=0x10000000 in the message this means our SDK did get the GCM payload.

W/GCM: broadcast intent callback: result=CANCELLED forIntent {
act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=in.oliveboard.prep (has extras) }

We have cleaned up this warning in version 3.10.2. https://github.com/OneSignal/OneSignal-Android-SDK/blob/3.10.2/OneSignalSDK/onesignal/src/main/java/com/onesignal/GcmBroadcastReceiver.java#L111-L116

If you seen result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE ...} with out flg=0x10000000 then this would be due to the app being force killed however.

This won't have any effect on the process is bad. error you originally posted but thought I would clear up the meaning behind that specific CANCELLED entry.

rameshvoltella commented 6 years ago

@jkasten2 you saying if i update to new release this issue will be resolved?

i want give an add on i tried the integrated of pushbots (https://pushbots.com/) to my app , i try the same steps in one plus, Push notification was getting all the time. i haven't miss any notification.

I tried

1)Swipe the app from task bar 2)Turn off the device and turn it on 3)Swipe the app and wait for more that 2 hours and tried sending(I got message)

All the above steps i succeed. I think we(onesignal) can also do this there is something we are missing i guess.

cirogg commented 5 years ago

could you make it? Im strugling with this. Everything works perfectly BUT when i kill the app and tap on a notification NOTHING happens.