fix(ios): remove stale notification authorization seam

This commit is contained in:
joshavant
2026-06-21 22:22:43 -05:00
committed by Josh Avant
parent 920bd04e19
commit 93c7ec645a
3 changed files with 2 additions and 38 deletions

View File

@@ -16,7 +16,6 @@ enum NotificationAuthorizationStatus {
protocol NotificationCentering: Sendable {
func authorizationStatus() async -> NotificationAuthorizationStatus
func requestAuthorization(options: UNAuthorizationOptions) async throws -> Bool
func add(_ request: UNNotificationRequest) async throws
func removePendingNotificationRequests(withIdentifiers identifiers: [String]) async
func removeDeliveredNotifications(withIdentifiers identifiers: [String]) async
@@ -48,10 +47,6 @@ struct LiveNotificationCenter: NotificationCentering, @unchecked Sendable {
}
}
func requestAuthorization(options: UNAuthorizationOptions) async throws -> Bool {
try await self.center.requestAuthorization(options: options)
}
func add(_ request: UNNotificationRequest) async throws {
try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
self.center.add(request) { error in

View File

@@ -14,10 +14,6 @@ private final class MockNotificationCenter: NotificationCentering, @unchecked Se
self.authorization
}
func requestAuthorization(options _: UNAuthorizationOptions) async throws -> Bool {
true
}
func add(_ request: UNNotificationRequest) async throws {
self.addedRequests.append(request)
}

View File

@@ -200,24 +200,12 @@ private final class MockWatchMessagingService: @preconcurrency WatchMessagingSer
private final class MockBootstrapNotificationCenter: NotificationCentering, @unchecked Sendable {
var status: NotificationAuthorizationStatus = .notDetermined
var requestAuthorizationResult = false
var requestAuthorizationCalls = 0
var addCalls = 0
func authorizationStatus() async -> NotificationAuthorizationStatus {
self.status
}
func requestAuthorization(options _: UNAuthorizationOptions) async throws -> Bool {
self.requestAuthorizationCalls += 1
if self.requestAuthorizationResult {
self.status = .authorized
} else {
self.status = .denied
}
return self.requestAuthorizationResult
}
func add(_: UNNotificationRequest) async throws {
self.addCalls += 1
}
@@ -1233,15 +1221,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
hasStoredOperatorToken: false))
}
@Test @MainActor func successfulBootstrapOnboardingDoesNotRequestNotificationAuthorization() async {
let center = MockBootstrapNotificationCenter()
let appModel = NodeAppModel(notificationCenter: center)
await appModel._test_handleSuccessfulBootstrapGatewayOnboarding()
#expect(center.requestAuthorizationCalls == 0)
}
@Test @MainActor func operatorGatewayRequestedEventShowsNotificationGuidanceWhenNotificationsOff() async throws {
let center = MockBootstrapNotificationCenter()
center.status = .notDetermined
@@ -1258,7 +1237,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
let prompt = try #require(appModel._test_pendingNotificationPermissionGuidancePrompt())
#expect(prompt.approvalId == "approval-notifications-off")
#expect(center.requestAuthorizationCalls == 0)
}
@Test @MainActor func suppressedOperatorGatewayRequestedEventDoesNotShowNotificationGuidance() async {
@@ -1277,7 +1255,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
stateversion: nil))
#expect(appModel._test_pendingNotificationPermissionGuidancePrompt() == nil)
#expect(center.requestAuthorizationCalls == 0)
}
@Test @MainActor func operatorGatewayResolvedEventClearsNotificationGuidancePrompt() async throws {
@@ -1364,7 +1341,7 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
#expect(res.error?.message.contains("CAMERA_DISABLED") == true)
}
@Test @MainActor func systemNotifyDoesNotRequestNotificationAuthorizationWhenOff() async throws {
@Test @MainActor func systemNotifyReturnsUnavailableWhenNotificationsOff() async throws {
let center = MockBootstrapNotificationCenter()
center.status = .notDetermined
let appModel = NodeAppModel(notificationCenter: center)
@@ -1380,7 +1357,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
#expect(res.ok == false)
#expect(res.error?.code == .unavailable)
#expect(res.error?.message == "NOT_AUTHORIZED: notifications")
#expect(center.requestAuthorizationCalls == 0)
#expect(center.addCalls == 0)
}
@@ -1398,11 +1374,10 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
let res = await appModel._test_handleInvoke(req)
#expect(res.ok)
#expect(center.requestAuthorizationCalls == 0)
#expect(center.addCalls == 1)
}
@Test @MainActor func chatPushWithoutSpeechDoesNotRequestNotificationAuthorizationWhenOff() async throws {
@Test @MainActor func chatPushWithoutSpeechReturnsUnavailableWhenNotificationsOff() async throws {
let center = MockBootstrapNotificationCenter()
center.status = .notDetermined
let appModel = NodeAppModel(notificationCenter: center)
@@ -1418,7 +1393,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
#expect(res.ok == false)
#expect(res.error?.code == .unavailable)
#expect(res.error?.message == "NOT_AUTHORIZED: notifications")
#expect(center.requestAuthorizationCalls == 0)
#expect(center.addCalls == 0)
}
@@ -1436,7 +1410,6 @@ private final class MockBootstrapNotificationCenter: NotificationCentering, @unc
let res = await appModel._test_handleInvoke(req)
#expect(res.ok)
#expect(center.requestAuthorizationCalls == 0)
#expect(center.addCalls == 1)
}