Schedule daily notifications with awesome notifications

33 views Asked by At

I tried to create routine tracker, where user would get notification everyday at some time to remind him about certain routine. This is the code I used to create it:

Future<void> createRoutineReminderNotification(TimeOfDay timeOfDay, String name) async {
  await AwesomeNotifications().createNotification(
    content: NotificationContent(
      id: name.hashCode.abs(),
      channelKey: 'scheduled_channel',
      title: '${Emojis.time_alarm_clock} Do you remember about $name?',
      body: 'Stay consistent and you will win!',
      notificationLayout: NotificationLayout.Default,
      wakeUpScreen: true,
      category: NotificationCategory.Reminder,
    ),
    actionButtons: [
      NotificationActionButton(
        key: 'MARK_DONE',
        label: 'Mark Done',
      ),
    ],
    schedule: NotificationCalendar(
      preciseAlarm: true,
      allowWhileIdle: true,
      timeZone: await AwesomeNotifications().getLocalTimeZoneIdentifier(),
      hour: timeOfDay.hour,
      minute: timeOfDay.minute,
      second: 0,
      millisecond: 0,
      repeats: true,
    ),
  );
}

The notification is displayed only one time and on the next day it doesn't show up anymore. Should I switch to local notifications or what could I change here?

0

There are 0 answers