0

我之前看过一个类似这样的问题,但答案是不需要许可,因为没有编辑......但是关于为什么没有显示用户提示的问题没有得到回答。
我的问题是我确实需要编辑,所以确实需要这个提示,以便用户可以授予权限。目前,我没有收到提示,因此访问总是“被拒绝”。

我的片段如下。(Xcode 7.2.1 iOS 9.2.1)任何帮助,提示将不胜感激。我没有看到任何其他有此问题的人,所以不知道问题是什么...我尝试了已弃用的 AB 方法以及相同的 NO 权限提示...是否有一些 plist 字符串需要设置为位置经理???
谢谢...

func checkContactsAccess() {
    switch CNContactStore.authorizationStatusForEntityType(.Contacts) {
        // Update our UI if the user has granted access to their Contacts
    case .Authorized:
        print("Access Granted")
        // Prompt the user for access to Contacts if there is no definitive answer
    case .NotDetermined :
        self.requestContactsAccess()

        // Display a message if the user has denied or restricted access to Contacts
    case .Denied,
    .Restricted:
        let alert = UIAlertController(title: "Privacy Warning!",
            message: "Permission was not granted for Contacts.",
            preferredStyle: .Alert)
        alert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
        self.presentViewController(alert, animated: true, completion: nil)
    }
}

func requestContactsAccess() {

    contactStore.requestAccessForEntityType(.Contacts) {granted, error in
        if granted {
            dispatch_async(dispatch_get_main_queue()) {
                print("Access Granted")
                return
            }
        }
    }
}
4

2 回答 2

0

使用联系人选择器视图的应用不需要访问用户的联系人,并且不会提示用户“授予权限”访问权限。该应用程序只能访问用户的最终选择。

CNCContactPickerViewController

于 2020-08-05T01:10:18.130 回答
-1

是否需要为位置管理器设置一些 plist 字符串

是的,当然有。并且名称完全平行:“Privacy - Contacts Usage Description”。

于 2016-03-18T17:58:07.890 回答