flutter_foreground_task
flutter_foreground_task copied to clipboard
App getting killed in background
I am using the Foreground task to keep my app alive when it's in the background. However, after some time which could be for 15 mins or 30 mins or an hour as well being uncertain, the app is killed along the foreground service. I do not do anything substantial in the foreground task other than what's in the example. I am using it to only keep the app alive in background. I am using Android 11 real device and have not called for batteryOptmization. Any guidance on this?
I'm getting reports, after client goes to sleep and wakes up, task notification disappears. Even when ignoring battery optimizations.
Some device manufacturers like Samsung, one plus,oppo, vivo and xiaomi have their own battery savers which kill the app and all of it's services no matter what. You have to explicitly disable them on your app settings and sadly there is no other way out.
@h2210316651 I'm thinking of setting up a periodic firebase messaging that will try to restart the service it has stopped working. Do you think it will help?
@h2210316651 I'm thinking of setting up a periodic firebase messaging that will try to restart the service it has stopped working. Do you think it will help?
Can you elaborate. firebase messaging as in Firebase Cloud Messaging?
@h2210316651 Yes FCM. When the app receives an FCM push notification, its handler will check if the service is running and run it if it isn't.
@SomeoneIsWorking Sounds like a plan. I think it'll work Provided it has access to the flutterforgroundtask singleton. Let me know if it works.
@SomeoneIsWorking @h2210316651 @akshg05 @Dev-hwang - Any solution found for this?
Any solution found for this?
@hardikamal We moved to using Firebase Cloud Messaging as the trigger mechanism for the recurring task
Service is Getting Closed After Some Time Notification is disappearing . even after disabled battery optimization . any solution for this ?
I have same problem. @RohitSadioura Did you find any solution?
No @aBuder
@aBuder
It would be helpful if you could tell me what caused the service to kill. This may be a memory problem or the service may be terminated according to the policy of a specific manufacturer and device. Using a service like the Firebase Crashlytics API
may be able to identify the problem.
@aBuder
If you're not communicating with dart main isolate, the settings below may help.
<service
android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
android:process=":remote" />
However, this separation of processes has the disadvantage of not being able to control the service.
@aBuder @RohitSadioura
Also try the options below:
<application
android:label="flutter_foreground_task_example"
android:icon="@mipmap/ic_launcher"
android:persistent="true"> <!-- this -->
</application>
No App will still closed
The problem I am trying to tackle now is app stops working in the background after some time but retains the sticky foreground notification. Our app counts steps so we make it in a way that it does that in the background and shows how many steps are counted in the sticky foreground notification. But many reports say the counter stops working and hangs at "x counted steps". I think this happens when the operating system tries to free resources by restarting the foreground service.