My app keep deny the access to contacts iOS - Swift

主宰稳场 提交于 2019-12-10 12:06:47

问题


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 ?


回答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.




回答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.

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.



来源:https://stackoverflow.com/questions/39327158/my-app-keep-deny-the-access-to-contacts-ios-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!