已安排本地通知停机工作NotificationRepeatFrequency

问题描述

当我尝试实现函数chedulednotificationRepeatFrequency并每天设置时,通知后的第二天没有出现?如何在确定的小时和分钟上设置每日通知? 这是我的代码

Future<void> _scheduleDailyNotification(
  int id,String title,int nday,int hour,int minute,) async {
  int nhour = hour - TimeOfDay.Now().hour;
  int nminute = minute - TimeOfDay.Now().minute;
  print(hour);
  print(nhour);
  print(nminute);
  var androidplatformchannelspecs = AndroidNotificationDetails(
  '1','xClock title','xClock description',channelAction: AndroidNotificationChannelAction.createIfNotExists,icon: 'ic_xclockicon',sound: RawResourceAndroidNotificationSound('ringstone'),largeIcon: DrawableResourceAndroidBitmap('ic_xclockicon'),);
  var iosplatformchannelspecs = IOSNotificationDetails(
    presentAlert: true,presentBadge: true,presentSound: true,sound: 'ringstone.wav');
  await FlutterlocalnotificationsPlugin.zonedSchedule(
  id,title,'xClock è tempo di $title',_nextInstanceOfTenAM(nday,nhour,nminute),NotificationDetails(
      android: androidplatformchannelspecs,iOS: iosplatformchannelspecs,macOS: null),androidAllowWhileIdle: true,uilocalnotificationDateInterpretation:
      UIlocalnotificationDateInterpretation.absoluteTime,schedulednotificationRepeatFrequency:
      SchedulednotificationRepeatFrequency.daily);
 }


tz.TZDateTime _nextInstanceOfTenAM(int nday,int nhour,int nminute) {
final tz.TZDateTime Now = tz.TZDateTime.Now(tz.local);
tz.TZDateTime scheduledDate = tz.TZDateTime.Now(tz.local)
  .add(Duration(days: nday,hours: nhour,minutes: nminute))
  .subtract(Duration(seconds: Now.second));

if (scheduledDate.isBefore(Now) || nday < 0) {
(scheduledDate.isBefore(Now))
    ? scheduledDate = scheduledDate.add(const Duration(days: 7))
    : scheduledDate = scheduledDate.add(const Duration(days: 0));
 } else {}
 print('schedule');
 print(scheduledDate);
 return scheduledDate;
 }

我尝试了FlutterlocalnotificationsPlugin.periodicallyShow,但我只能选择每天,每小时,每周,每分钟,但我也想选择弹出窗口的时间

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)