2

My app was rejected by the apple review team. According to them the reason is

"17.1: Apps cannot transmit data about a user without obtaining the user's prior permission and providing the user with access to information about how and where the data will be used.Specifically, your app accesses the Users contacts with out requesting permission first"

But, I have used **NSContactsUsageDescription** key in my info.plst to specify the reason of using contacts in my app.

What should I have to do additionally for get permission?

4

2 回答 2

3

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

在此处输入图像描述

像这个例子的实现代码的方法:

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];
}
于 2013-07-31T06:05:54.750 回答
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();
}
于 2013-07-31T09:08:39.410 回答