저는 현재 일정 응용 프로그램을 만들고 있으며 매주 특정 요일에 특정 시간에 특정 지역의 알림을 작성하려고합니다. . 그래서 내가하는 첫 번째 일은 이벤트의 시작 시간의 날짜 값을 얻은 다음 시작 시간 값에서 5 분을 뺀 다음 알림을 예약합니다. (상관없이스위프트 3의 날짜 선택 도구에서 발동 날짜가있는 매주 반복 가능한 지역 알림 예약
let someMinutesEarlier = Calendar.current.date(byAdding: .minute, value: -5, to: startTimePicker.date)
let contentOfNotification = UNMutableNotificationContent()
let interval = someMinutesEarlier?.timeIntervalSinceNow
contentOfNotification.title = "Event starting"
contentOfNotification.body = "Some notes"
contentOfNotification.sound = UNNotificationSound.default()
let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: interval!, repeats: true)
let request = UNNotificationRequest.init(identifier: notificationIdentifier, content: contentOfNotification, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.add(request) { (error) in
print(error as Any)
}
하지만,이 경우에만 일정 알림 번만 : 이전에는 단지 매우 쉬웠다 입력했다 : notification.repeatInterval = CalendarUnit.WeekOfYear
을하지만 지금은 명령 스위프트 3에서 사용되지 않으며 그래, 내가 볼 수있는 유일한 방법입니다 repeat 부울이 true로 설정 됨), someMinutesEarlier의 연도로 인해 ... 아니면 다른 것일 수 있습니까? 어떤 생각? McNight가 했나요으로
왜 당신은 UNCalendarNotificationTrigger를 사용하지 않는? – McNight
ios10 또는 ios10보다 이전 버전 만 타겟팅합니까? 10보다 이전 버전에서도 앱을 실행하고 싶다면 지금은 더 이상 사용되지 않는 방식을 고수 할 것입니다. 그렇지 않으면 두 버전을 모두 쓰고'available '을 사용해야합니다. – Paulw11