我需要在用户关闭(禁用)时使用切换关闭来自myApp的联系人访问权限。 切换时,获取联系人权限将打开(启用)。
有任何想法如何解决。
答案 0 :(得分:0)
首先,我想告诉您Apple不允许以任何Apple授权方式修改隐私设置,以编程方式........所以如果您想处理此问题,您可以检查是否允许如果它被授予或不被.....那么你可以处理你的事件a / c ....这个方法将从本机OS发出警报,要求访问....
//Ask user to grant the permission to access contacts
- (void)requestPermissionForContactsAccessAndFetchWithCompletion
{
ABAuthorizationStatus status = ABAddressBookGetAuthorizationStatus();
if (status != kABAuthorizationStatusAuthorized && status != kABAuthorizationStatusNotDetermined) {
// tell user to enable contacts in privacy settings
NSLog(@"You previously denied access: You must enable access to contacts in settings");
}
CFErrorRef error = NULL;
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, &error);
if (error)
{
if (addressBook) CFRelease(addressBook);
}
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (error) {
NSLog(@"ABAddressBookRequestAccessWithCompletion error: %@", CFBridgingRelease(error));
}
if (granted) {
//Get all contact if access is granted--This will call when access granted
[self getContactsFromAddressBook:addressBook];
}else{
}
});
}
如果您需要更多帮助,请告诉我....