我想在下次触发通知时检索

时间:2018-01-31 14:30:15

标签: ios swift

我使用in local表示repeatInterval,是否可以检索repeatInterval再次运行的时间?我需要这个来更新计数器“在触发通知之前剩下多少”。

1 个答案:

答案 0 :(得分:1)

如果您定位iOS 10+,则应使用UNUserNotificationCenter

UNUserNotificationCenter方法getPendingNotificationRequests(completionHandler:)将在待处理通知请求的完成处理程序列表中返回。

列表的每个元素都是UNNotificationRequest对象,其中包含属性trigger

如果触发器为UNTimeIntervalNotificationTriggerUNCalendarNotificationTrigger,则其方法nextTriggerDate()将为您提供下次触发时的时间点。

它看起来像你在寻找什么。