I'm trying to use the Flutter android_alarm_manager to create some background tasks but can't seem to get it working without the firebase auth. I followed the readme on the plugin, but just adding the android_alarm_manager
plugin in the pubspec.yaml
causes the app to crash immediately (emulator and real device) on startup. How can I avoid the Firebase integration and still use the alarm manager plugin?
Re: but can't seem to get it working without the firebase auth
Maybe at the time of your attempt back in 2018, there was some unintended entangling or some other issue in your app, but as of now, https://pub.dev/packages/android_alarm_manager does not require any Firebase.
Just need to set up some permissions, a service, and receivers in the manifest, then this sample is runnable:
import 'package:android_alarm_manager/android_alarm_manager.dart';
void printHello() {
final DateTime now = DateTime.now();
final int isolateId = Isolate.current.hashCode;
print("[$now] Hello, world! isolate=${isolateId} function='$printHello'");
}
main() async {
final int helloAlarmID = 0;
await AndroidAlarmManager.initialize();
runApp(...);
await AndroidAlarmManager.periodic(const Duration(minutes: 1), helloAlarmID, printHello);
}
Also see /flutter/android_alarm_manager/example/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With