Foreground service example in Flutter

Viewed 10178

I am new to Flutter. Can anyone post the link or code for "android foreground service example with a notification"? I googled but didn't get any good example of foreground service.

I'm working on a project that includes an SMS package. This App has to be active on the foreground.

4 Answers

Update:

I have created my own implementation of android foreground service for Flutter called android_long_task. check it out it solved my problem. let me know if it solves your problem by raising an issue.I created my own library because the tutorial I mentioned just shows how to create a foreground service in java and that's all and as you have found out by now the other foregorund_service plugins have some problems.

Old answer (didn't help me):

if you're having a problem with this and none of the libraries mentioned in other answers worked for you. you might wanna give this tutorial from RetroPortal Studio a try. it's a total of 26 minutes which teaches you how to write a working foreground service for flutter android

I tried flutter_foreground_service but it has a big problem. When app closes this plugin throwing error. This bug is reported in here: https://github.com/pauldemarco/foreground_service/issues/1

foreground_service has problem too: https://github.com/pauldemarco/foreground_service/issues/1

Probably there isn't a good solution for now (Jan 2020). If someone develops a good solution may be I add it to here.

I think Google should find solution for this kind of problems. We're using flutter becouse we're thinking that flutter is more effective. If we lost our time kind of this absurd errors why we using flutter? Using kotlin for android, swift for ios this is more good probably.

Pauldemarco has created some excellent flutter packages for flutter. He has developed one for Foreground service too. As of now, it is only supported in android. It is not supported for iOS. I hope this helps.

https://github.com/pauldemarco/foreground_service

Related