Contact Usage permission request iphone

2019-07-20 20:51发布

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?

2条回答
再贱就再见
2楼-- · 2019-07-20 21:10

In iOS 6 You Need to use Address-book permission request iphone to access it's Device Contact:-

enter image description here

method of implement code like this example:

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];
}
查看更多
叛逆
3楼-- · 2019-07-20 21:34

You have to ask user whether your application can access your Address book. This feature is implemented in iOS 6.0 and above.

You Can try this code Snippet:

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

in - 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();
}
查看更多
登录 后发表回答