zonedSchedule method

int zonedSchedule(
  1. TZDateTime? schedule, {
  2. int? id,
  3. String? title,
  4. String? body,
  5. String? payload,
  6. bool? androidAllowWhileIdle,
  7. UILocalNotificationDateInterpretation? uiLocalNotificationDateInterpretation,
  8. DateTimeComponents? matchDateTimeComponents,
  9. String? icon,
  10. Importance? importance,
  11. Priority? priority,
  12. StyleInformation? styleInformation,
  13. bool? playSound,
  14. AndroidNotificationSound? sound,
  15. bool? enableVibration,
  16. List<int>? vibrationPattern,
  17. String? groupKey,
  18. bool? setAsGroupSummary,
  19. GroupAlertBehavior? groupAlertBehavior,
  20. bool? autoCancel,
  21. bool? ongoing,
  22. Color? color,
  23. AndroidBitmap<Object>? largeIcon,
  24. bool? onlyAlertOnce,
  25. bool? showWhen,
  26. int? when,
  27. bool? usesChronometer,
  28. bool? channelShowBadge,
  29. bool? showProgress,
  30. int? maxProgress,
  31. int? progress,
  32. bool? indeterminate,
  33. AndroidNotificationChannelAction? channelAction,
  34. bool? enableLights,
  35. Color? ledColor,
  36. int? ledOnMs,
  37. int? ledOffMs,
  38. String? ticker,
  39. NotificationVisibility? visibility,
  40. int? timeoutAfter,
  41. String? category,
  42. bool? fullScreenIntent,
  43. String? shortcutId,
  44. Int32List? additionalFlags,
  45. String? subText,
  46. String? tag,
  47. bool? presentAlert,
  48. bool? presentSound,
  49. bool? presentBadge,
  50. String? soundFile,
  51. int? badgeNumber,
  52. List<IOSNotificationAttachment>? attachments,
  53. List<MacOSNotificationAttachment>? macAttachments,
  54. String? subtitle,
  55. String? threadIdentifier,
})

Displays a scheduled Notification.

Implementation

int zonedSchedule(
  TZDateTime? schedule, {
  int? id,
  String? title,
  String? body,
  String? payload,
  bool? androidAllowWhileIdle,
  UILocalNotificationDateInterpretation?
      uiLocalNotificationDateInterpretation,
  DateTimeComponents? matchDateTimeComponents,
  String? icon,
  Importance? importance,
  Priority? priority,
  StyleInformation? styleInformation,
  bool? playSound,
  AndroidNotificationSound? sound,
  bool? enableVibration,
  List<int>? vibrationPattern,
  String? groupKey,
  bool? setAsGroupSummary,
  GroupAlertBehavior? groupAlertBehavior,
  bool? autoCancel,
  bool? ongoing,
  Color? color,
  AndroidBitmap<Object>? largeIcon,
  bool? onlyAlertOnce,
  bool? showWhen,
  int? when,
  bool? usesChronometer,
  bool? channelShowBadge,
  bool? showProgress,
  int? maxProgress,
  int? progress,
  bool? indeterminate,
  AndroidNotificationChannelAction? channelAction,
  bool? enableLights,
  Color? ledColor,
  int? ledOnMs,
  int? ledOffMs,
  String? ticker,
  NotificationVisibility? visibility,
  int? timeoutAfter,
  String? category,
  bool? fullScreenIntent,
  String? shortcutId,
  Int32List? additionalFlags,
  String? subText,
  String? tag,
  bool? presentAlert,
  bool? presentSound,
  bool? presentBadge,
  String? soundFile,
  int? badgeNumber,
  List<IOSNotificationAttachment>? attachments,
  List<MacOSNotificationAttachment>? macAttachments,
  String? subtitle,
  String? threadIdentifier,
}) {
  // May have already been supplied.
  if (schedule == null && _schedule != null) {
    schedule ??= _schedule as TZDateTime;
  }

  // Too late!
  if (schedule == null || DateTime.now().isAfter(schedule)) {
    return -1;
  }

  final notificationSpecifics = _notificationDetails(
    title,
    body,
    payload,
    androidAllowWhileIdle,
    icon,
    importance,
    priority,
    styleInformation,
    playSound,
    sound,
    enableVibration,
    vibrationPattern,
    groupKey,
    setAsGroupSummary,
    groupAlertBehavior,
    autoCancel,
    ongoing,
    color,
    largeIcon,
    onlyAlertOnce,
    showWhen,
    when,
    usesChronometer,
    channelShowBadge,
    showProgress,
    maxProgress,
    progress,
    indeterminate,
    channelAction,
    enableLights,
    ledColor,
    ledOnMs,
    ledOffMs,
    ticker,
    visibility,
    timeoutAfter,
    category,
    fullScreenIntent,
    shortcutId,
    additionalFlags,
    subText,
    tag,
    presentAlert,
    presentSound,
    presentBadge,
    soundFile,
    badgeNumber,
    attachments,
    macAttachments,
    subtitle,
    threadIdentifier,
  );

  if (notificationSpecifics == null) {
    id = -1;
  } else {
    //
    if (id == null || id < 0) {
      id = Random().nextInt(999);
    }

    try {
      //
      _flutterLocalNotificationsPlugin!.zonedSchedule(
        id,
        title,
        body,
        schedule,
        notificationSpecifics,
        uiLocalNotificationDateInterpretation:
            uiLocalNotificationDateInterpretation ??
                UILocalNotificationDateInterpretation.absoluteTime,
        androidAllowWhileIdle: androidAllowWhileIdle ?? true,
        payload: payload,
        matchDateTimeComponents: matchDateTimeComponents,
      );
    } catch (ex) {
      id = -1;
      getError(ex);
    }
  }
  return id;
}