【发布时间】:2018-11-22 10:36:52
【问题描述】:
这是我的功能。我的功能是在打开应用程序并在 10 秒前杀死应用程序时显示通知,但我想知道仅在关闭应用程序时如何捕捉时间间隔
func showNotification(title: String, body: String) {
// Configure the notification's payload.
let content = contentNotification(title: title, body: body)
// Deliver the notification in five seconds.
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 10, repeats: false)
let request = UNNotificationRequest(identifier: "FiveSecond", content: content, trigger: trigger) // Schedule the notification.
let center = UNUserNotificationCenter.current()
// UNUserNotificationCenter.current().delegate = (self as! UNUserNotificationCenterDelegate)
center.add(request) { (error: Error?) in
if error != nil {
// Handle any errors
print("err Noti = \(error.debugDescription)")
}
}
}
【问题讨论】:
-
你的问题很不清楚。你能准确描述一下吗?
-
我想知道我们只关闭应用程序时设置警报通知的时间间隔
标签: swift notifications local