Min*_*ael 1 debugging permissions contacts ios6
appstore上的我的应用程序正在访问iPhone联系人,用户在iOS 6上下载它后无法访问iPhone联系人,而它在iOS 5上工作正常问题是苹果在iOS 6中提供的新隐私设置..所以搜索后我发现我必须在我的代码中执行以下操作才能访问用户联系人:
//in order to test addressbook availability we have to attempt to create an addressbook instance using ABAddressBookCreateWithOptions
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef,
^(bool granted, CFErrorRef error) {
if (granted)
[self loadContacts];
});
} else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self loadContact];
} else {
}
#endif //end iOS6+
//ABAddressBookCreateWithOptions not available or succeeded. return YES;
[self loadContacts];
Run Code Online (Sandbox Code Playgroud)
我现在的问题是在设备上调试时,警报没有显示,我不知道为什么?我知道上面的代码应该可以正常工作,但只有当应用程序提交到appstore但我想在提交之前在调试模式下测试它?有什么建议?
感谢您的支持.谢谢.
我设法让它解决了这是稍微修改后的新代码:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
__block MyClassType *controller = self;
// Request authorization to Address Book
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, NULL);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef,
^(bool granted, CFErrorRef error) {
if (granted)
[controller loadContacts];
});
} else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self loadContacts];
} else {
}
#else
[self loadContacts];
#endif
Run Code Online (Sandbox Code Playgroud)
能够测试它的关键是从设置>>常规>>重置>>重置位置和隐私重置隐私和位置设置
它对我很好.
| 归档时间: |
|
| 查看次数: |
3816 次 |
| 最近记录: |