zonedSchedule method

Future<void> zonedSchedule(
  1. int id,
  2. String? title,
  3. String? body,
  4. TZDateTime scheduledDate,
  5. AndroidNotificationDetails? notificationDetails, {
  6. required AndroidScheduleMode scheduleMode,
  7. String? payload,
  8. DateTimeComponents? matchDateTimeComponents,
})

Schedules a notification to be shown at the specified date and time relative to a specific time zone.

The scheduleMode parameter defines the precision of the timing for the notification to be appear.

This will also require additional setup for the app, especially in the app's AndroidManifest.xml file. Please see check the readme for further details.

Implementation

Future<void> zonedSchedule(
  int id,
  String? title,
  String? body,
  TZDateTime scheduledDate,
  AndroidNotificationDetails? notificationDetails, {
  required AndroidScheduleMode scheduleMode,
  String? payload,
  DateTimeComponents? matchDateTimeComponents,
}) async {
  validateId(id);
  validateDateIsInTheFuture(scheduledDate, matchDateTimeComponents);

  await _channel.invokeMethod(
    'zonedSchedule',
    <String, Object?>{
      'id': id,
      'title': title,
      'body': body,
      'platformSpecifics':
          _buildPlatformSpecifics(notificationDetails, scheduleMode),
      'payload': payload ?? '',
      ...scheduledDate.toMap(),
      if (matchDateTimeComponents != null)
        'matchDateTimeComponents': matchDateTimeComponents.index
    },
  );
}