2017-11-05 8 views
0

だから私は次のコードで次の通知を取得することができます:すぐに到着する通知の日付を取得するには?

let center = UNUserNotificationCenter.current() 
    center.getPendingNotificationRequests { (notifications) in 

     let pendingNotifications : [UNNotificationRequest] = notifications 
     let notification = pendingNotifications[0] 
     let trigger = notification.trigger 
     let content = notification.content 
    } 

トリガーが私を取得...

時間:16 分:10 第二:0は、繰り返される:YES>

しかし、私はtrigger.dateComponentsを呼び出すことができません

この日付はどのようにして取得できますか?

答えて

1

あなたはUICalendarNotificationTriggerにUNNotificationTriggerをキャストし、そのnextTriggerDate

if let calendarNotificationTrigger = notifications.first?.trigger as? UNCalendarNotificationTrigger, 
    let nextTriggerDate = calendarNotificationTrigger.nextTriggerDate() { 
    print(nextTriggerDate) 
} 
を取得する必要があります
関連する問題