flutter_background_service
flutter_background_service copied to clipboard
Feature request: Can these services optionally be configured to auto-boot?
First off: Love the plugin, does exactly what is promised and works even better than I expected (Isolate can use other plugins like sensors or http calls!)
But now I'm getting greedy: How would I go about setting a 'service' created with your plugin to automatically start when the phone is rebooted?
@3SCadmin the service will started at boot automatically, but you have to ensure your app is autostart enabled by the os. Some os e.g MIUI has built in security to manage which app allowed to autostart. You also to turn off battery optimization for your app, so the os won't terminate your application when it's in the background.
Ok, I didn't realise that is already part of the package features.
I did a little test using your example code (didn't want my code to be a variable) Used a Samsung Note 10 (Android 11) and a cheap no-name (Android 6)
1.) After reboot I need to pin-unlock the device before anything happens. 2.) I can see that the service is trying to start.. 3.) Under notifications it gets as far as "Background Service Preparing"
But that's as far as it get's on it's own. Only after I have 'activated' the GUI of the app, does the example's background service begin it's loop again.
Any advice on what needs to be done to get the service looping without user interaction?
@3SCadmin the service won't started before user unlock pin after boot. if you want to start service unless devices locked after booting, you can read Direct Boot Mode.
@3SCadmin the service won't started before user unlock pin after boot. if you want to start service unless devices locked after booting, you can read Direct Boot Mode.
Fair enough.
But the issue I seem to have is: After pin-unlock the example service does not start it's loop. It only shows "Background Service Preparing" in notifications.
How I get the service to properly auto-start?
This is quite complicated, because there are so many device vendors that modify the OS to suit their needs. We can't say for sure what works on one device will work on another. So, we need to gather a lot of input from other developers who have worked on this.
Ok, I'll keep an eye out for future updates. Still a great plugin that helps me a lot
Thank you.
#80 Here the solution