I can use local notifications like this

awesome_notifications: ^0.6.21

Notification class

class NotificationService {
  sendNotification(){
    AwesomeNotifications().isNotificationAllowed().then((isAllowed){
      if(!isAllowed){
        AwesomeNotifications().requestPermissionToSendNotifications();
      }
    });
    AwesomeNotifications().createNotification(content: NotificationContent(id: 2, channelKey: 'key',
    title: 'Title',
      body: 'Body',
    ),
    );
    AwesomeNotifications().actionStream.listen((event) {
      Get.toNamed(Routes.HOME_PAGE);
    });
  }
}

Main call

void main() {
  AwesomeNotifications().initialize(null, [NotificationChannel(channelKey: 'key', channelName: 'channelName', channelDescription: 'channelDescription')]);
  runApp(const MyApp());
}

My question is how to schedule the notification for example at 4:00 pm daily in the background ?


Solution 1: Sapto Sutardi

If you want repeats it.. Repeats is determines if the schedule should be repeat after be displayed... Change your "AwesomeNotifications().createNotification" function.

String localTimeZone = await AwesomeNotifications().getLocalTimeZoneIdentifier();

AwesomeNotifications().createNotification(
      content: NotificationContent(
          id: id,
          channelKey: 'scheduled',
          title: 'Notification at every 24 hours or 1440 minutes',
          body:
              'This notification was schedule to repeat at every 24 hours or 1440 minutes.',
          notificationLayout: NotificationLayout.BigPicture,
          bigPicture: 'asset://assets/images/melted-clock.png'), 
      schedule: NotificationInterval(interval: 1440, timeZone: localTimeZone, repeats: true));

Look at: https://pub.dev/packages/awesome_notifications