[英]iOS Simulator does not show permission alert
My app uses Address Book framework. 我的应用程序使用通讯簿框架。 To show all contacts in iOS 6 or higher I have to set permission for it.
要显示iOS 6或更高版本中的所有联系人,我必须为其设置权限。
At first time when I was running my app on the simulator I saw this alert below, but when I try to show it again I don't see the alert one more time. 第一次在模拟器上运行应用程序时,我在下面看到此警报,但是当我尝试再次显示它时,我再也没有看到该警报。
I have reseted content and settings but it has not helped me. 我重设了内容和设置,但并没有帮助我。 So when I rerun app it all time shows contacts, but at first the app has to show alert when I reseted simulator.
因此,当我重新运行应用程序时,所有时间都会显示联系人,但是首先,当我重置模拟器时,该应用程序必须显示警报。 Anybody faced with this issue?
有人遇到这个问题吗?
Code below: 代码如下:
- (void)getPersonOutOfAddressBook
{
if (self.tableData) {
[self.tableData removeAllObjects];
}
ABAddressBookRef addressBook = ABAddressBookCreate();
__block BOOL accessGranted = NO;
if (ABAddressBookRequestAccessWithCompletion != NULL) { // we're on iOS 6
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
accessGranted = granted;
dispatch_semaphore_signal(sema);
});
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
dispatch_release(sema);
}
else
{
// we're on iOS 5 or older
accessGranted = YES;
}
if (accessGranted)
{
if (addressBook != nil)
{
NSLog(@"Succesful.");
NSArray *allContacts = (__bridge_transfer NSArray
*)ABAddressBookCopyArrayOfAllPeople(addressBook);
NSUInteger i = 0;
for (i = 0; i < [allContacts count]; i++)
{
Contact *contact = [[Contact alloc] init];
ABRecordRef contactPerson = (__bridge ABRecordRef)allContacts[i];
NSString *firstName = (__bridge_transfer NSString
*)ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty);
NSString *lastName = (__bridge_transfer NSString
*)ABRecordCopyValue(contactPerson, kABPersonLastNameProperty);
NSString *fullName = [NSString stringWithFormat:@"%@ %@",
firstName, lastName];
NSData *imgData = (__bridge NSData *)ABPersonCopyImageData(contactPerson);
contact.firstName = firstName;
contact.lastName = lastName;
contact.fullName = fullName;
contact.image = [UIImage imageWithData:imgData];
[self.tableData addObject:contact];
}
CFRelease(addressBook);
}
}
}
My experience is: when you install an app to your device it will ask you to allow or not something. 我的经验是:将应用程序安装到设备上时,它会要求您允许或不允许进行某些操作。 If you delete it and install it again it won't ask you again.
如果您删除它并重新安装,它不会再询问您。 For example an app want to know you enable or disable push messages.
例如,某个应用程序想知道您启用或禁用了推送消息。 If you tell: yes I enable, and then you remove the app from the device, and after you download again, and install it won't ask you again.
如果您说:是,启用,然后从设备中删除该应用程序,并在再次下载并安装后不再询问您。 It s just automaticly appears in your settings.
它只是自动出现在您的设置中。 Address book can work the same , but I'm not sure.
通讯录可以使用相同的功能,但是我不确定。 GPS is not the same, applications ask you evertime to enable location.
GPS并不相同,应用程序会要求您随时启用定位。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.