스위프트 4 &> 아이폰 OS 10.0 나는 특정 날짜에 주어진 시간에 지역 알림을 예약 할알림 센터 및 변경 시간대
(의 오후 3을 가정 해 봅시다). 나는 시간대에 관계없이 (시간대에 따른 알림의 자동 일정 재조정) 오전 3시에 알림이 언제나 해고되기를 바랍니다.
이전에 this SO post에 완벽하게 설명 된 것과 같이 정확히 UILocalNotifications
'시간대를 조정하여 정확하게 달성 할 수있었습니다. 그러나 >iOS 10.0
에서 UILocalNotifications
은 사용되지 않습니다. 여기
func scheduleNotification(title: String, message: String, atDate: Date){
let center = UNUserNotificationCenter.current()
// Create content
let content = UNMutableNotificationContent()
content.title = title
content.body = message
content.sound = UNNotificationSound.default()
// Create trigger
let calendar = Calendar(identifier: .gregorian)
let triggerDate = calendar.dateComponents([.year,.month,.day,.hour,.minute,.second,], from: atDate)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: false)
// Create identifier
let identifier = "\(UUID())"
// Create request & add to center
let request = UNNotificationRequest(identifier: identifier,
content: content,
trigger: trigger)
center.add(request, withCompletionHandler: { (error) in
})
}
질문 : 가 어떻게 알림이 시간대를 변경하는 제대로 트리거해야합니까?