请求用户对联系人的权限时的自定义消息
Custom message when requesting user's permission to Contacts
我正在使用此代码请求访问联系人 UI:
let store = CNContactStore()
store.requestAccess(for: .contacts) { (granted, error) in
if let error = error {
print(error)
}
if granted {
completionHandler(.granted)
} else {
completionHandler(.denied)
}
}
但我想在出现的警报弹出窗口中显示一条自定义消息,详细说明我需要访问用户联系人的原因。我该怎么做?
进入您的 Info.plist
文件,添加以下键 NSContactsUsageDescription
,并在值字段中添加您的自定义警报消息。
我正在使用此代码请求访问联系人 UI:
let store = CNContactStore()
store.requestAccess(for: .contacts) { (granted, error) in
if let error = error {
print(error)
}
if granted {
completionHandler(.granted)
} else {
completionHandler(.denied)
}
}
但我想在出现的警报弹出窗口中显示一条自定义消息,详细说明我需要访问用户联系人的原因。我该怎么做?
进入您的 Info.plist
文件,添加以下键 NSContactsUsageDescription
,并在值字段中添加您的自定义警报消息。