From e6a501b070090b333165996e4ec2f577582865c4 Mon Sep 17 00:00:00 2001 From: David <36027902+EchoLunar@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:00:31 +0800 Subject: [PATCH] Adapt ContactsPermission to iOS 18, changing the limited status to return as authorized. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After iOS 18, a new status limited was added to CNAuthorizationStatus - ‘This application is authorized to access some contact data.’ In the limited status, I tried using CNContactStore to fetch contact data, and it successfully retrieved the corresponding data selected by the user. Therefore, I believe this status should be treated as authorized. --- Sources/ContactsPermission/ContactsPermission.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/ContactsPermission/ContactsPermission.swift b/Sources/ContactsPermission/ContactsPermission.swift index 73597de9..45cfc1ff 100644 --- a/Sources/ContactsPermission/ContactsPermission.swift +++ b/Sources/ContactsPermission/ContactsPermission.swift @@ -40,7 +40,11 @@ public class ContactsPermission: Permission { open var usageDescriptionKey: String? { "NSContactsUsageDescription" } public override var status: Permission.Status { - switch CNContactStore.authorizationStatus(for: .contacts) { + let authorizationStatus = CNContactStore.authorizationStatus(for: .contacts) + if #available(iOS 18.0, *), authorizationStatus == .limited { + return .authorized + } + switch authorizationStatus { case .authorized: return .authorized case .denied: return .denied case .notDetermined: return .notDetermined