From 55485c71e6700ce2c060f2d236615d1338e44bc6 Mon Sep 17 00:00:00 2001 From: Jamil Date: Wed, 15 Jan 2025 08:34:55 -0800 Subject: [PATCH] fix(apple/macOS): Don't log notificationsNotAllowed (#7762) This can happen if the user hasn't granted notifications and isn't worth reporting. --- .../FirezoneKit/Views/UpdateNotification.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/UpdateNotification.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/UpdateNotification.swift index 3fb2e22fa..1de6188a1 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/UpdateNotification.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Views/UpdateNotification.swift @@ -107,9 +107,17 @@ private class NotificationAdapter: NSObject, UNUserNotificationCenterDelegate { notificationCenter.delegate = self notificationCenter.requestAuthorization(options: [.sound, .badge, .alert]) { _, error in - if let error = error { - Log.error(error) + guard let error = error else { return } + + // If the user hasn't enabled notifications for Firezone, we may receive + // a notificationsNotAllowed error here. Don't log it. + if let unError = error as? UNError, + unError.code == .notificationsNotAllowed { + return } + + // Log all other errors + Log.error(error) } }