iOS 10用户通知不允许每隔一段时间重复通知

iOS 10用户通知不允许每隔一段时间重复通知,ios,swift,Ios,Swift,有了新的iOS 10用户通知框架,人们再也不能将通知安排在每分钟或每小时重复一次的特定日期或时间 如何在用户通知框架中执行此操作?我发现: 您可以尝试为UNNotificationResponse定义类别,然后根据类别类型处理响应 func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationRespon

有了新的iOS 10用户通知框架,人们再也不能将通知安排在每分钟或每小时重复一次的特定日期或时间

如何在用户通知框架中执行此操作?

我发现:

您可以尝试为UNNotificationResponse定义类别,然后根据类别类型处理响应

func userNotificationCenter(_ center: UNUserNotificationCenter,
                            didReceive response: UNNotificationResponse,
                            withCompletionHandler completionHandler: @escaping () -> Void) {
    if response.notification.request.content.categoryIdentifier == "TIMER_EXPIRED" {
        // Handle the actions for the expired timer.
        if response.actionIdentifier == "SNOOZE_ACTION" {
            // Invalidate the old timer and create a new one. . .
        }
        else if response.actionIdentifier == "STOP_ACTION" {
            // Invalidate the timer. . .
        }
    }

    // Else handle actions for other notification types. . .
}

您可以根据时间、日历或位置触发通知。触发器可以重复:

let date = Date(timeIntervalSinceNow: 60)
let triggerMinute = Calendar.current.dateComponents([.minute,.second], from: date)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerMinute, repeats: true)

此代码尝试安排通知,以便日期的分钟和秒组件相匹配,您可以按照自己的方式对其进行配置。

我不希望用户对通知执行任何操作