AndroidAlarmManager periodic does not trigger with startAt

50 Views Asked by At

using the flutter package android_alarm_manager_plus, I was hoping the startAt would cause the periodic schedule to trigger at the startAt time before it runs periodically based on the duration provided according to the documentation

"If startAt is passed, the timer will first go off at that time and subsequently run with period duration."

but this never fires. it's almost like the startAt is ignored.

dumping my code bellow

@pragma('vm:entry-point')
void test() {
  final LoggingService logger = LoggingService();
  final now = DateTime.now();

  logger.debug('I got called periodic at ${now.toIso8601String()}');
}

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await AndroidAlarmManager.initialize();

  final now = DateTime.now();

  AndroidAlarmManager.periodic(
    const Duration(days: 1),
    now.millisecondsSinceEpoch.hashCode + 1,
    test,
    startAt: DateTime(now.year, now.month, now.day, 04, 58),
    rescheduleOnReboot: true,
    exact: true,
    wakeup: true,
  );

so the idea here is to start the periodic callback at my specific time " 04:58" then set the duration to 1 day so it repeats daily at "04:58"

am I missing something here?

0

There are 0 best solutions below