最終更新:2017-07-11 (火) 05:00:42 (2472d)  

UserNotifications
Top / UserNotifications

https://developer.apple.com/documentation/usernotifications

主なクラス

条件

  • UNCalendarNotificationTrigger?
  • UNTimeIntervalNotificationTrigger?
  • UNLocationNotificationTrigger?

主な処理

  • UNUserNotificationCenter addNotificationRequest:withCompletionHandler:?

  • let content = UNMutableNotificationContent()
    content.title = NSString.localizedUserNotificationString(forKey: "Wake up!", arguments: nil)
    content.body = NSString.localizedUserNotificationString(forKey: "Rise and shine! It's morning time!",
     arguments: nil)
    
    // 午前7時のモーニングコール用にトリガを設定。
    var dateInfo = DateComponents()
    dateInfo.hour = 7
    dateInfo.minute = 0
    let trigger = UNCalendarNotificationTrigger(dateMatching: dateInfo, repeats: false)
    
    // リクエストオブジェクトを生成。
    let request = UNNotificationRequest(identifier: "MorningAlarm", content: content, trigger: trigger)