I have a view when it get loaded it will check first the permission to access the contacts if it's Authorized, NotDetermined or Denied .. the code at first time will go with NotDetermined so it will call function to ask for access .. the problem is here in this function :
private func requestContactsAccess() {
//store = CNContactStore()
store.requestAccessForEntityType(.Contacts) {granted, error in
if granted {
dispatch_async(dispatch_get_main_queue()) {
self.accessGrantedForContacts()
return
}
}
}
}
Now the app never ask for access to Contacts , I don't know why, it will select the permission as denied by its self .
I don't know if the problem with the code or the simulator because this work for other people .
Note : when I go to the settings of the sim , Setteings > Privacy > Contacts .. I find nothing ! just saying : 'Applications that have requested access to your contacts will appear here' . which mean the app never ask for it !
Any help ?
First time when code executed, popup appears for permission of accessing contact list. Which button you tapped on that popup? (Allow or Don't Allow) ?
I think you have unintentionally tapped don't allow. Please go to Settings -> -> Allow to access Contacts -> Set switch to YES.
I'm not sure if this is your problem but if you're running your app on iOS 10 Simulator you need to provide a "usage description" for accessing private information like Contacts (camera, camera roll, etc.).
Open your Info.plist and add a new entry and you will see new "Privacy - ..." settings.
Select "Privacy - Contacts Usage Description" and type in a usage description. See if this helps.
When run you should see the grant access popup with your usage description.