Search code examples
ioscontactsui

Custom message when requesting user's permission to Contacts


I'm using this code to request access to the Contacts UI:

        let store = CNContactStore()
        store.requestAccess(for: .contacts) { (granted, error) in
            if let error = error {
                print(error)
            }
            if granted {
                completionHandler(.granted)
            } else {
                completionHandler(.denied)
            }
        }

But I want to show a custom message in the alert pop up that shows up, detailing why I need to access the user's contacts. How can I do that?


Solution

  • Go into your Info.plist file, add the following key NSContactsUsageDescription, and add your custom alert message in the value field.