Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like AlarmManager in Flutter?

Tags:

flutter

I need to schedule the execution of some lines of code in the future just as AlarmManager does. That is:

  • Schedule your application to be run at some point in the future.

  • Automatically start the target application if it is not already running.

  • Wake up the device if it is asleep.

Of course I would need to have support for iOS.

I found scheduled_notifications but it doesn't seem to cover all these conditions.

Any help is very welcome.

like image 443
RobertoAllende Avatar asked Jun 19 '17 04:06

RobertoAllende


People also ask

What is Alarm Manager?

AlarmManager is a bridge between application and Android system alarm service. It can send a broadcast to your app (which can be completely terminated by user) at a scheduled time and your app can then perform any task accordingly.


2 Answers

As of late 2017 we now have an android_alarm_manager package for accessing the Android AlarmManager service, and running Dart code in the background when alarms fire.

like image 197
Michael Thomsen Avatar answered Oct 23 '22 06:10

Michael Thomsen


Flutter doesn't currently provide a mechanism to run Dart code in the background without a FlutterView. Follow issue 3671 for updates.

You probably don't want to launch your main activity immediately when the alarm goes off, because that would be very disruptive, so your best bet for the moment is probably to solve this problem using regular Java and Objective-C code in the standard way.

like image 35
Collin Jackson Avatar answered Oct 23 '22 07:10

Collin Jackson