I am trying to run a piece of dart code when the android device boots up. Ideally, the code should run immediately or with a small delay (1-2 minutes at most). I don't want the app to start up, just a headless piece of code to run.
My Use Case:
I am working on an alarm clock application, and I want to handle the alarms that go off when the device is turned off, like disabling one-time alarms, and scheduling the next alarm if it's a repeat alarm. I can't afford to wait for long to handle these cases in case a repeat alarm was scheduled to ring shortly after the user boots up the device.
What I Have Tried:
I have tried doing it with flutter_background_fetch, with headless: true
and startOnBoot: true
. But it runs the code at 15 minutes intervals, which is too long for my use case, as explained above.