SayWut / flutter_foreground_service_plugin

MIT License
12 stars 12 forks source link

feature: configurable notificationChannel importance #3

Open toonvanstrijp opened 3 years ago

toonvanstrijp commented 3 years ago

It would be nice if we could specify the importance of the notification channel. This would allow a silent notification (one that doesn't appear continuously)

NotificationChannel chan1 = new NotificationChannel("default", "default", NotificationManager.IMPORTANCE_LOW);
SayWut commented 3 years ago

Its already implemented

image

or do you mean to somthing else?

toonvanstrijp commented 3 years ago

@SayWut wow that's exactly what I meant! How did I miss that... :) my bad!

toonvanstrijp commented 3 years ago

Screenshot_20210105-015540_One UI Home

It didn't work as expected. How can I have it the same as the "Android System" notification. That one is collapsed from the beginning :)

SayWut commented 3 years ago

When I implemented this I checked if this works

The single line notification it depends on the OS and every android OS works differently, on some you need to use LOW on other you need to use MIN

I am not in front of my PC right now, I will check this later but you can try this for now

https://stackoverflow.com/questions/50676819/android-o-single-line-notification-like-the-android-system-usb-charging-t

SayWut commented 3 years ago

from what I checked and tested there is no way to create a single line foreground service in android 8

when you use importance min the OS change the importance to higher lvl

Min notification importance: only shows in the shade, below the fold. This should not be used with Service#startForeground(int, Notification) since a foreground service is supposed to be something the user cares about so it does not make semantic sense to mark its notification as minimum importance. If you do this as of Android version Build.VERSION_CODES.O, the system will show a higher-priority notification about your app running in the background.

https://developer.android.com/reference/android/app/NotificationManager#IMPORTANCE_MIN

toonvanstrijp commented 3 years ago

I don't know if it makes a difference, but I'm using android 10 in the image above.

SayWut commented 3 years ago

I don't know if it makes a difference, but I'm using android 10 in the image above.

🤔 I will check on this

SayWut commented 3 years ago

I tried to play with it and I didn't find any solution that works, if you manage to create single line notification send me the solution I will try to implement it. From what I tested and searched it is not possible to set the ForegroudService's notification importance lower then medium programmatically which is crucial for single line notification

toonvanstrijp commented 3 years ago

Alright I'll test around and if I find something I'll let you know.