3
iOS8의 주소록에 연락처를 추가하려고합니다. 더 이상 그렇게 할 수 없습니다. 여기 내 코드는 다음과 같습니다.iOS 8 주소록에 연락처 추가
-(void)addPersonToAddressBook {
NSString * fullName = integrationDictionary[@"fullName"];
ABPeoplePickerNavigationController *pp =[ABPeoplePickerNavigationController new];
ABAddressBookRef addressBook = [pp addressBook];
ABRecordRef entry = ABPersonCreate();
CFErrorRef cfError=nil;
ABRecordSetValue(entry, kABPersonFirstNameProperty, (__bridge CFTypeRef)(fullName) , nil);
ABAddressBookAddRecord(addressBook, entry, &cfError);
if (ABAddressBookSave(addressBook, &cfError)) {
NSString *saveMessage = [NSString stringWithFormat:@"%@ has been added to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Contact Added" message:saveMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
} else {
NSString *saveMessage = [NSString stringWithFormat:@"There was an error adding %@ to your address book.", fullName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Uh Oh" message:saveMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
NSLog(@"error is %@", cfError);
오류가 null로 표시됩니다. 이걸 본 사람 있어요? 해결 방법은 무엇입니까?
을 - 당신이 확인하는 경우 문이 안되는'' 사용자가 실제로 앱 액세스 권한을 부여했는지 확인하기위한 'BOOL'' 값 – Supertecnoboff
@Supertecnoboff 그것은 내재적 결함이있는 예일뿐입니다 ... 나는 OP에 답변했습니다. – Razvan