-
StackOverflow 文档
-
iOS 教程
-
联系框架
-
授权联系人访问
导入框架
迅速
import Contacts
Objective-C
#import <Contacts/Contacts.h>
检查可访问性
迅速
switch CNContactStore.authorizationStatusForEntityType(CNEntityType.Contacts){
case .Authorized: //access contacts
case .Denied, .NotDetermined: //request permission
default: break
}
Objective-C
switch ([CNContactStore authorizationStatusForEntityType:CNEntityType.Contacts]){
case CNAuthorizationStatus.Authorized:
//access contacts
break;
case CNAuthorizationStatus.Denied:
//request permission
break;
case CNAuthorizationStatus.NotDetermined:
//request permission
break;
}
请求许可
迅速
var contactStore = CKContactStore()
contactStore.requestAccessForEntityType(CKEntityType.Contacts, completionHandler: { (ok, _) -> Void in
if access{
//access contacts
}
}