因此,我一直在试图实现iOS 10本地通知,首先我认为代码与iOS 9相同,只是添加通知扩展目标。然而,它实际上使用UNMutableNotificationContent
类,本地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
,我希望我可以只添加一个日期。
我必须使用当前日期和日期选择器日期来计算间隔时间吗?或者我可以用其他方法做到这一点