联系人使用权限请求iPhone [英] Contact Usage permission request iphone

查看:108
本文介绍了联系人使用权限请求iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用被Apple审核小组拒绝了.据他们说,原因是

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

"17.1:应用程序无法传输有关用户的数据,除非获得用户的事先许可并向用户提供访问权限 有关如何以及在何处使用数据的信息.特别是, 您的应用在没有请求权限的情况下访问了用户联系人 首先"

"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"

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

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?

推荐答案

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

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)

- 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();
}

这篇关于联系人使用权限请求iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆