我的应用程序拒绝访问iOS通讯录-Swift [英] My app keep deny the access to contacts iOS - Swift

查看:119
本文介绍了我的应用程序拒绝访问iOS通讯录-Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,当它被加载时,它将首先检查访问联系人的权限,如果它是Authorized,NotDetermined或Denied ..第一次代码将与NotDetermined一起使用,因此它将调用函数以请求访问权限..问题出在此函数中:

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 .

注意:当我进入SIM卡的设置时,Setteings>隐私>联系人.只是说:请求访问您的联系人的应用程序将出现在这里".这意味着该应用程序永远不会要求它!

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 !

有帮助吗?

推荐答案

我不确定这是否是您的问题,但是如果您在iOS 10 Simulator上运行应用程序,则需要提供使用说明"以进行访问私人信息,例如联系人(相机,相机胶卷等).

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.).

打开Info.plist并添加一个新条目,您将看到新的隐私-..."设置.

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.

这篇关于我的应用程序拒绝访问iOS通讯录-Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆