diff --git a/Airship/AirshipCore/Source/PermissionsManager.swift b/Airship/AirshipCore/Source/PermissionsManager.swift index fe3f91f2f..08cfcd507 100644 --- a/Airship/AirshipCore/Source/PermissionsManager.swift +++ b/Airship/AirshipCore/Source/PermissionsManager.swift @@ -183,14 +183,9 @@ public final class AirshipPermissionsManager: NSObject, @unchecked Sendable { } let startingStatus = await delegate.checkPermissionStatus() - var endStatus: AirshipPermissionStatus = .notDetermined - - switch(startingStatus) { - case .granted: - endStatus = .granted - case .notDetermined: - endStatus = await delegate.requestPermission() - case .denied: + var endStatus: AirshipPermissionStatus = await delegate.requestPermission() + + if startingStatus == .denied, endStatus == .denied { switch fallback { case .none: endStatus = .denied diff --git a/Airship/AirshipCore/Tests/PermissionsManagerTests.swift b/Airship/AirshipCore/Tests/PermissionsManagerTests.swift index 20e6e22d2..95a266fbd 100644 --- a/Airship/AirshipCore/Tests/PermissionsManagerTests.swift +++ b/Airship/AirshipCore/Tests/PermissionsManagerTests.swift @@ -103,7 +103,7 @@ class PermissionsManagerTests: XCTestCase { let status = await self.permissionsManager.requestPermission(.location) XCTAssertEqual(AirshipPermissionStatus.denied, status) - XCTAssertFalse(self.delegate.requestCalled) + XCTAssertTrue(self.delegate.requestCalled) XCTAssertTrue(self.delegate.checkCalled) } @@ -117,7 +117,7 @@ class PermissionsManagerTests: XCTestCase { let status = await self.permissionsManager.requestPermission(.location) XCTAssertEqual(AirshipPermissionStatus.granted, status) - XCTAssertFalse(self.delegate.requestCalled) + XCTAssertTrue(self.delegate.requestCalled) XCTAssertTrue(self.delegate.checkCalled) } @@ -131,7 +131,7 @@ class PermissionsManagerTests: XCTestCase { _ = await self.permissionsManager.requestPermission(.location, enableAirshipUsageOnGrant: false, fallback: .systemSettings) - XCTAssertFalse(self.delegate.requestCalled) + XCTAssertTrue(self.delegate.requestCalled) XCTAssertTrue(self.delegate.checkCalled) XCTAssertEqual(systemSettingsNavigator.permissionOpens, [.location]) } @@ -148,7 +148,7 @@ class PermissionsManagerTests: XCTestCase { _ = await self.permissionsManager.requestPermission(.location, enableAirshipUsageOnGrant: false, fallback: .systemSettings) - XCTAssertFalse(self.delegate.requestCalled) + XCTAssertTrue(self.delegate.requestCalled) XCTAssertTrue(self.delegate.checkCalled) XCTAssertEqual(systemSettingsNavigator.permissionOpens, [.location]) } @@ -170,7 +170,7 @@ class PermissionsManagerTests: XCTestCase { ) XCTAssertEqual(AirshipPermissionStatus.granted, status.endStatus) - XCTAssertFalse(self.delegate.requestCalled) + XCTAssertTrue(self.delegate.requestCalled) XCTAssertTrue(self.delegate.checkCalled) }