如何为UNTimeIntervalNotificationTrigger创建动态请求?

时间:2020-07-02 09:25:37

标签: ios swift

这是我在代码中使用的示例用法:

func notificationRequestsForTimer() -> [UNNotificationRequest] {
    let content = UNMutableNotificationContent()
    content.title = Options.shared.currentTimeInSeconds.descriptiveTime
    content.body = "go and go"
    let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
    let request = UNNotificationRequest(identifier: TimerNotificationIdentifier, content: content, trigger: trigger)
    return [request]
}

但是每60秒我就会获得标题:0', 0', 0' ...而不是0', 1', 2', 3'

是否可以在即将出现通知时安排通知并设置标题?

0 个答案:

没有答案