Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to dynamically toggle the notification, allowing a foreground service to become background only, and back again? #306

Open
leaf-node opened this issue Dec 6, 2024 · 0 comments

Comments

@leaf-node
Copy link

Thank you for flutter_foreground_task!

I was using flutter_local_notifications (a different package) to create a foreground notification associated with an isolate in my Android app, but isolates are not separate processes / services, so really the foreground notification seems to keep the entire app process alive, which may be wasteful, and isn't always reliable.

So I thought that I'd create two ways to communicate with an isolate or service depending on the platform, using flutter_foreground_task for Android. Depending on potential features in this package, it could be pretty easy, or more complex than I originally thought.

The requested feature is to be able to dynamically remove this package's sticky notification while allowing the service to continue running as a background service. When hiding the notification, it would tie the lifetime of the service with the lifetime of the rest of the app. Re-showing the notification would also persist the service as being foreground again.

The main benefit of such a feature is that occasionally turning all notifications off via my app's internal settings allows Android to save battery by closing the app when the user doesn't need to see them.

My app needs its back end to be active at least all the time that the app is running. So, without the proposed feature, I may have to create a class that proxies requests, and stops, starts, and switches between back ends, one being an internal isolate, and the other being a foreground service created via this package.

Although that could work as a a workaround, it wouldn't be as ideal as being able to dynamically control the life cycle of the service. Would switching between a foreground and background service be something you'd be willing to add to your package?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant