UILocalNotificationので、私はUserNotificationの枠組みに自分のコードを更新したいと思い減価償却されています:UserNotification - iOSの10
私は似て毎日または時間ごとの繰り返しを設定するにはどうすればよいlet alertDays = 3.0
let alertSeconds = alertDays * 24.0 * 60.0 * 60.0
let localNotification:UILocalNotification = UILocalNotification()
localNotification.alertAction = "Reminder"
localNotification.alertTitle = "Reminder Title"
localNotification.alertBody = "Reminder Message"
localNotification.fireDate = Foundation.Date(timeIntervalSinceNow: alertSeconds)
localNotification.repeatInterval = .day
UIApplication.shared().scheduleLocalNotification(localNotification)
最初の通知を待ってからUserNotificationフレームワークを使用しますか?
let alertDays = 3.0
let alertSeconds = alertDays * 24.0 * 60.0 * 60.0
let content: UNMutableNotificationContent = UNMutableNotificationContent()
content.title = "Reminder Title"
content.subtitle = "Reminder Subtitle"
content.body = "Reminder Message"
let calendar = Calendar.current
let alarmTime = Foundation.Date(timeIntervalSinceNow: alertSeconds)
let alarmTimeComponents = calendar.components([.day, .hour, .minute], from: alarmTime)
let trigger = UNCalendarNotificationTrigger(dateMatching: alarmTimeComponents, repeats: true)
let request = UNNotificationRequest(identifier: workoutAlarmIdentifier,
content: content,
trigger: trigger)
UNUserNotificationCenter.current().add(request)
{
(error) in // ...
}
関連? [iOS 10 UserNotificationsでNSCalendarUnitMinute repeatIntervalを設定する方法は?](http://stackoverflow.com/q/37804287/2415822) – JAL
関連していますが、UserNotificationsでサポートされている償却されたUILocalNotificationsの.repeatIntervalはありません。これが新しいフレームワークでどのように処理されるかを探して、償却されたコードから自分のコードを移動することができます。 –
あなたがレーダーを上げることを提案します – Wain