【问题标题】:Custom message when requesting user's permission to Contacts [duplicate]请求用户对联系人的权限时的自定义消息[重复]
【发布时间】:2018-03-16 17:12:45
【问题描述】:

我正在使用此代码请求访问联系人 UI:

        let store = CNContactStore()
        store.requestAccess(for: .contacts) { (granted, error) in
            if let error = error {
                print(error)
            }
            if granted {
                completionHandler(.granted)
            } else {
                completionHandler(.denied)
            }
        }

但我想在弹出的警报中显示一条自定义消息,详细说明我需要访问用户联系人的原因。我该怎么做?

【问题讨论】:

    标签: ios contactsui


    【解决方案1】:

    进入您的Info.plist 文件,添加以下键NSContactsUsageDescription,并在值字段中添加您的自定义警报消息。

    【讨论】:

    • 我在 plist 中找到了一个名为“Privacy - Contacts Usage Description”的键,这就是我需要更改以使文本出现的地方。谢谢!
    • @Rod 那是NSContactsUsageDescription 键——当你添加它时,属性列表会自动将它转换成更易读的东西
    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 2020-09-03
    • 2013-07-31
    • 2017-07-18
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多