gpt4 book ai didi

ios - UNCalendarNotificationTrigger 每小时触发器返回错误的触发日期

转载 作者:行者123 更新时间:2023-11-30 13:05:31 26 4
gpt4 key购买 nike

我正在使用以下方法来每小时触发一次本地通知。

let reminderTrigger = UNCalendarNotificationTrigger.init(dateMatching: NSCalendar.current.dateComponents([.minute], from: dateStart), repeats: true)
let notificationRequest = UNNotificationRequest(identifier: "reminder", content: reminderContent, trigger: reminderTrigger)

这是基于 Apple 的文档 - https://developer.apple.com/reference/usernotifications/uncalendarnotificationtrigger

但是,当我打印下一个触发日期时,它完全错误。

print(dateStart)
print(reminderTrigger.nextTriggerDate())

这是输出 -

2016-09-10 05:18:58 +0000
Optional(2016-09-11 04:00:06 +0000)

但是,应该是

2016-09-10 06:00:00 +0000

我以类似的方式尝试了每日、每周、每月、每年,它们都返回正确的下一个触发日期。每小时是唯一看起来不正确的。有什么想法吗?

最佳答案

我也遇到了和你一样的问题

        UNNotificationRequest *request = notifyDict[[NSString stringWithFormat:@"%ld", indexPath.row]];
UNTimeIntervalNotificationTrigger *trigger = (UNTimeIntervalNotificationTrigger *)request.trigger;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss"];
NSString *strDate = [dateFormatter stringFromDate:trigger.nextTriggerDate];

我获取了触发器的nextTriggerDate,但该日期不是我之前为触发器设置的值。

关于ios - UNCalendarNotificationTrigger 每小时触发器返回错误的触发日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39422888/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com