scheduleNotification method

Future<bool> scheduleNotification({
  1. required int id,
  2. required String title,
  3. required String message,
  4. required DateTime scheduledTime,
  5. String? channelId,
  6. NotificationImportance? importance,
  7. bool alarmSound = false,
  8. String? targetScreen,
  9. Map<String, dynamic>? extraData,
})

Schedule a notification to be shown by the operating system at a fixed time, even when the app is fully closed (a real background service).

This uses the platform's native scheduling APIs (Android AlarmManager, iOS/macOS UNUserNotificationCenter calendar triggers, Windows scheduled toasts, Linux detached timer) so no external plugin is required.

  • id must be unique; use it later to cancel the notification.
  • scheduledEpochMillis is the delivery time as milliseconds since epoch.
  • alarmSound plays a louder, alarm-like sound (high importance channel).

Returns true when the notification was scheduled.

Implementation

Future<bool> scheduleNotification({
  required int id,
  required String title,
  required String message,
  required DateTime scheduledTime,
  String? channelId,
  NotificationImportance? importance,
  bool alarmSound = false,
  String? targetScreen,
  Map<String, dynamic>? extraData,
}) {
  return NotificationMasterPlatform.instance.scheduleNotification(
    id: id,
    title: title,
    message: message,
    scheduledEpochMillis: scheduledTime.millisecondsSinceEpoch,
    channelId: channelId,
    importance: importance,
    alarmSound: alarmSound,
    targetScreen: targetScreen,
    extraData: extraData,
  );
}