CNContactPicker 不提示访问被拒绝
CNContactPicker not prompting access denied
我之前见过一个这样的问题,但答案是不需要许可,因为没有编辑...但是没有回答为什么没有显示用户提示的问题。
我的问题是我确实需要编辑所以确实需要这个提示以便用户可以授予权限。目前,我没有收到提示,所以访问始终是 "denied"。
我的片段如下。 (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
}
}
}
}
Is there some plist string that needs to be set like for location manager
是的,当然有。而且名字完全平行:"Privacy — Contacts Usage Description".
The app using contact picker view does not need access to the user’s contacts and the user will not be prompted for “grant permission” access. The app has access only to the user’s final selection.
我之前见过一个这样的问题,但答案是不需要许可,因为没有编辑...但是没有回答为什么没有显示用户提示的问题。
我的问题是我确实需要编辑所以确实需要这个提示以便用户可以授予权限。目前,我没有收到提示,所以访问始终是 "denied"。
我的片段如下。 (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
}
}
}
}
Is there some plist string that needs to be set like for location manager
是的,当然有。而且名字完全平行:"Privacy — Contacts Usage Description".
The app using contact picker view does not need access to the user’s contacts and the user will not be prompted for “grant permission” access. The app has access only to the user’s final selection.