0

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 ?

Zizoo
  • 1,694
  • 5
  • 20
  • 42

2 Answers2

2

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. 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. enter image description here

Mark Moeykens
  • 15,915
  • 6
  • 63
  • 62
1

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.

santak
  • 327
  • 1
  • 13
  • @zizoo you can also try resetting your simulator to check default behavior. – santak Sep 05 '16 at 09:24
  • First , Thank you.. second, I did not select Don't Allow because in the question I mentioned that the app always go to NotDetermined case not denied then it will call this method to request the access , this method by default not asking for access it will chose the Don't Allow choice , that's my problem, Then after that the access will be denied because of this method – Zizoo Sep 05 '16 at 09:31