【问题标题】:Notification not triggering for a time(FLutter)通知没有触发一段时间(FLutter)
【发布时间】:2021-08-31 14:06:03
【问题描述】:

如何使用 flutter_local_notification 包触发特定时间段的通知。我尝试了 pub.dev 上的教程,但我仍然无法做到。有人,请帮忙。

这是我在下午 4:23 触发它的尝试。

  tz.TZDateTime _nextInstanceOfTenAM() {
final tz.TZDateTime now = tz.TZDateTime.now(tz.local);
tz.TZDateTime scheduledDate =
tz.TZDateTime(tz.local, now.year, now.month, now.day, 16, 23));
if (scheduledDate.isBefore(now)) {
  scheduledDate = scheduledDate.add(const Duration(days: 1));
}
return scheduledDate;



Future<void> displayNotification() async {
notificationsPlugin.zonedSchedule(
    0,
    "Wake Up",
    'Time to wake up now',
    _nextInstanceOfTenAM(),
    //tz.TZDateTime.now(tz.local).add(Duration(seconds: 3)),
    NotificationDetails(
      android: AndroidNotificationDetails(
          'channel id', 'channel name', 'channel description'),
    ),
    uiLocalNotificationDateInterpretation:
    UILocalNotificationDateInterpretation.absoluteTime,
    androidAllowWhileIdle: true);

}

【问题讨论】:

    标签: android flutter dart time flutter-local-notification


    【解决方案1】:

    【讨论】:

    • 但我并没有关闭应用程序......它仍然没有触发
    • 另外,我可以将通知安排在当前时间 3 秒后,但我无法执行上述命令.....请尽快提供帮助
    猜你喜欢
    • 2021-07-19
    • 1970-01-01
    • 2011-06-27
    • 1970-01-01
    • 2020-05-30
    • 1970-01-01
    • 2016-12-24
    • 2022-11-28
    • 2015-11-30
    相关资源
    最近更新 更多