UNTimeIntervalNotificationTrigger
とUNUserNotificationCenterDelegate
のiOS 10.2で奇妙なバグが発生しています。基本的に私が作成した通知は、すぐにデリゲートによって取得され、正しい内部で再度取得されています。これは、トリガーでrepeatプロパティがtrueに設定されている場合にのみ発生します。iOS 10.2 UNUserNotificationCenterDelegate/UNTimeIntervalNotificationTriggerバグ?
他にもこの問題がありますか?今私はデリゲートのトリガー日付をチェックし、登録された登録日付と比較する必要があると考えていますが、可能ならばそれを避けたいと思います。
サンプルコードは、私は偽の繰り返しにトリガを変更した場合
let content = UNMutableNotificationContent()
content.body = "My notification message"
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: true)
let request = UNNotificationRequest(identifier: "MY_IDENTIFIER", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
UNUserNotificationCenterDelegateが.add
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
// Code called here instantly when trigger repeats = true
// Code called again at proper interval as well (60 seconds)
}
直後に解雇された通知を作成するには、これはを発生しません。
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 60, repeats: false)
文書では、「繰り返しがtrueの場合、timeIntervalパラメータの値は60秒以上にする必要があります。あなたがライン上にいるので、より大きな間隔を選び、何が起こるかを見る方が良いのではないかと思うようになります。 – matt
実際には複数日設定されていますが、ここでサンプルコードを60に変更しました。 –