katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

Always on notification not showing in Android 8 Oreo #334

Open dimitriscsd opened 6 years ago

dimitriscsd commented 6 years ago

Just got Oreo on my Oneplus 3T and I noticed that the app notification is not showing. Instead you get the new android one saying that the app is running in the background draining battery. If you click that one it takes you to the app info page.

Have also confirmed this to be the case on a Google Pixel XL on Oreo.

This problem makes extremely difficult to get back to the app if you have excluded it from the recents list. The only way to get back is if you go through the app drawyer or a shortcut on your desktop.

UPDATE: I looked into this a bit further and it looks like it stopped working with Android platform version 6.3.0 I ran the example app provided by the plugin with 6.2.2 and the notification shows up fine. If I try to use 6.3.0 it doesn't show. Hopefully this helps.

TrayserCassa commented 6 years ago

This might be helpful :)

https://stackoverflow.com/questions/35573485/ionic-add-platform-android-with-custom-android-target

YoSarin commented 6 years ago

For me it doesn't matter which version of cordova-android i try. I tried 5.2.2, 6.2.2, 7.1.0 and still getting just default android notification (at Android 8.0). But setting target SDK version (as TrayserCassa suggested) lower than 26 worked. Even with cordova-android@7.1.0

dimitriscsd commented 6 years ago

Just confirming this, since I opened the ticket. Changing the targetSDK version to 25, makes the icon appear as normal.

I wonder if this affects or breaks anything else.

It would be nice if this could be fixed with newer SDK versions so we didn't have to get stuck on 25.

tushe commented 6 years ago

Same problem with Android 8 on Galaxy A3 2017 and Galaxy A5 2017...

tushe commented 6 years ago

From august 2018 sdk target version must be 26 to upload on PlayStore, we should find a solution...

ryanrasmussen05 commented 6 years ago

Confirming same issue on Galaxy S8. Setting target version to 25 shows notification, but that won't be allowed on Play Store later this year. Would be great to get a fix for this, otherwise its not usable for me @katzer

Marix1 commented 6 years ago

Same on Note8, Note3, Note5, Nexus 6P

Android 5.x to 7.x i can use sdk 25 - 26...

Android 8.x only targetsdk-25 work

sdk-26 there is no notification

tushe commented 6 years ago

Notifications are changed in sdk-26, check Android documentation at:

https://developer.android.com/guide/topics/ui/notifiers/notifications#ManageChannels

https://developer.android.com/training/notify-user/build-notification

I think steps to modify 'ForegroundService.java' file are:

1) check wich Android version is it 2) if it's >= Android 8 use a different flow to manage notifications with NotificationChannel

tushe commented 6 years ago

Resolved --> https://github.com/tushe/cordova-plugin-background-mode

israndi commented 5 years ago

thanks tushe, its work 👍 👍 👍