【发布时间】:2016-09-07 01:49:57
【问题描述】:
所以我一直在尝试实现 iOS 10 本地通知,首先我认为代码与 iOS 9 相同,只是添加了一个通知扩展目标。但是它实际上使用了UNMutableNotificationContent 类,
我可以使用时间间隔设置带有通知的通知,但是如何使用日期选择器专门设置触发日期?
import UserNotifications
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .full
let displayDate = dateFormatter.string(from: datePicker.date)
let notif = UNMutableNotificationContent()
notif.title = "Reminder)"
notif.subtitle = "\(displayDate)"
notif.body = "Details"
notif.categoryIdentifier = "Details Reminder"
let notifTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false)
let request = UNNotificationRequest(identifier: "myNotif", content: notif, trigger: notifTrigger)
UNNotificationRequest 触发器需要 UNTimeIntervalNotificationTrigger 类型,我希望我可以添加一个日期。
我是否必须使用当前日期和日期选择器日期来计算间隔时间?或者我可以通过其他方式做到这一点
【问题讨论】: