ローカル通知の繰り返しパターンはどれだけあるの?|matchDateTimeComponents|FlutterLocalNotifications|Android|Flutter


FlutterLocalNotifications 13.0.0 で繰り返しのスケジュールを作成する場合は「zonedSchedule」を使うけど、その中の「matchDateTimeComponents」に指定できるパラメータが分かり難くて迷っちゃった。以下は公式の説明。

There is an optional matchDateTimeComponents parameter that can be used to schedule a notification to appear on a daily or weekly basis by telling the plugin to match on the time or a combination of day of the week and time respectively.

実装上の「matchDateTimeComponents」に指定するパラメータの定義は以下だ。

---
/// The components of a date and time representations.
enum DateTimeComponents {
  /// The time.
  time,

  /// The day of the week and time.
  dayOfWeekAndTime,

  /// The day of the month and time.
  dayOfMonthAndTime,

  /// The date and time.
  dateAndTime,
}
---

この定義のコメントも分からなくなった要因のひとつなんだけど、公式の Example を確認した結果、ようやく意味が理解できた。

  • time : 毎日 XX 時にローカル通知する(用途は目覚ましアラームなどかな)
  • dayOfWeekAndTime : 毎週 XX 曜日 XX 時にローカル通知する(用途は習い事などかな)
  • dayOfMonthAndTime : 毎月 XX 日 XX 時にローカル通知する(用途は振込日などかな)
  • dateAndTime : 毎年 XX 月 XX 日 XX 時にローカル通知する(用途は誕生日などかな)


関連する記事


直近に読んでいた漫画(おすすめ)

コメント

このブログの人気の投稿

ImagePicker を操作すると「Lost connection to device.」とだけ言い残して強制終了するの?|iOS|Flutter

Android SDK バージョン(コンパイルに使用する Android API レベル)を変更するの?|compileSdkVersion|SDK|Android|Flutter