联系使用权限请求iphone

时间:2013-07-31 06:01:45

标签: iphone ios appstore-approval privacy

苹果审核小组拒绝了我的应用。根据他们的原因是

  

“17.1:应用无法在未获得用户事先许可的情况下传输有关用户的数据并向用户提供访问权限   有关数据使用方式和位置的信息。具体来说,   您的应用无需请求权限即可访问用户联系人   第一“

但是,我在**NSContactsUsageDescription**中使用了info.plst键来指定在我的应用中使用联系人的原因。

获得许可我还需要做些什么?

2 个答案:

答案 0 :(得分:3)

在iOS 6中你需要使用地址簿权限请求iphone来访问它的设备联系人: -

enter image description here

实现代码的方法,如下例所示:

ABAddressBookRef addressBook;
if ([self isABAddressBookCreateWithOptionsAvailable]) {
    CFErrorRef error = nil;
    addressBook = ABAddressBookCreateWithOptions(NULL,&error);
    ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
        // callback can occur in background, address book must be accessed on thread it was created on
        dispatch_async(dispatch_get_main_queue(), ^{
            if (error) {

            } else if (!granted) {


            } else {
                // access granted
                 [self GetAddressBook];


            }
        });
    });
} else {
    // iOS 4/5

     [self GetAddressBook];
}

答案 1 :(得分:2)

您必须询问用户您的应用程序是否可以访问您的地址簿。此功能在iOS 6.0及更高版本中实现。

您可以尝试使用此代码代码段:

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
- viewWillAppear:

中的

// Asking access of AddressBook
// if in iOS 6
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) 
{ 
    // Request authorization to Address Book
    addressBook_ = ABAddressBookCreateWithOptions(NULL, NULL);

    if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
    {
         ABAddressBookRequestAccessWithCompletion(addressBook_, ^(bool granted, CFErrorRef error)
                                                 {
                                                     if (granted == NO)
                                                     {
                                                         // Show an alert for no contact Access
                                                     }
                                                 });
    }
    else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized)
    {
        // The user has previously given access, good to go
    }
    else
    {
        // The user has previously denied access
        // Send an alert telling user to change privacy setting in settings app
    }
}
else // For iOS <= 5
{
    // just get the contacts directly
    addressBook_ = ABAddressBookCreate();
}