本文介绍了弹出请求访问联系人不显示ios 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从地址簿中获取联系人,但弹出窗口未显示以请求访问联系人的权限。它会自动被拒绝,但是当我在演示中尝试相同的代码时,它运行正常,但它不能在我的应用程序中运行。
我读了很多文章,但我没有得到任何解决方案。我是否缺少plist或设置中的内容。
I'm fetching contacts from address book but popup not show to ask permission to access contacts. it automatically denied but when i try same code in a demo then it run properly but it ddi not run in my app.I have read many articles but i did not get any solution. Is i'm missing something in plist or settings.
CNContactStore * contactStore = [[CNContactStore alloc]init];
if ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusNotDetermined) {
[contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * __nullable error) {
if (granted==YES)
{
}
else
{
NSLog(@"Error");
}
}];
}
或第二种方法
CFErrorRef error = nil;
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error)
{
if (error)
{
NSLog(@"error %@", error);
}
else if (granted)
{
}
CFRelease(addressBook);
});
}
推荐答案
我也是今天有这个问题,我从Info.plist中删除了一些密钥:
I also had this issue today, and I deleted some keys from Info.plist:
<key>CFBundleDisplayName</key>
<string></string>
<key>LSApplicationCategoryType</key>
<dict/>
<key>CFBundleGetInfoString</key>
<string></string>
现在可以使用了。有线外壳。
It works now. wired case.
这篇关于弹出请求访问联系人不显示ios 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!