Skip to content

Commit

Permalink
support prefix, suffix, nickname, department, note on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhocho committed Dec 29, 2016
1 parent 79492f6 commit 50ada5c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ios/RCTContacts/RCTContacts.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ -(NSDictionary*) dictionaryRepresentationForABPerson:(ABRecordRef) person
NSString *givenName = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonFirstNameProperty));
NSString *familyName = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonLastNameProperty));
NSString *middleName = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonMiddleNameProperty));
NSString *prefix = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonPrefixProperty));
NSString *suffix = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonSuffixProperty));
NSString *nickname = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonNicknameProperty));
NSString *company = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonOrganizationProperty));
NSString *department = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonDepartmentProperty));
NSString *jobTitle = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonJobTitleProperty));
NSString *note = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonNoteProperty));

[contact setObject: recordID forKey: @"recordID"];

Expand All @@ -121,14 +126,34 @@ -(NSDictionary*) dictionaryRepresentationForABPerson:(ABRecordRef) person
[contact setObject: (middleName) ? middleName : @"" forKey:@"middleName"];
}

if(prefix){
[contact setObject: (prefix) ? prefix : @"" forKey:@"prefix"];
}

if(suffix){
[contact setObject: (suffix) ? suffix : @"" forKey:@"suffix"];
}

if(nickname){
[contact setObject: (nickname) ? nickname : @"" forKey:@"nickname"];
}

if(company){
[contact setObject: (company) ? company : @"" forKey:@"company"];
}

if(department){
[contact setObject: (department) ? department : @"" forKey:@"department"];
}

if(jobTitle){
[contact setObject: (jobTitle) ? jobTitle : @"" forKey:@"jobTitle"];
}

if(note){
[contact setObject: (note) ? note : @"" forKey:@"note"];
}

if(!hasName){
//nameless contact, do not include in results
return nil;
Expand Down Expand Up @@ -312,13 +337,23 @@ -(void) updateRecord:(ABRecordRef)record onAddressBook:(ABAddressBookRef)address
NSString *givenName = [contactData valueForKey:@"givenName"];
NSString *familyName = [contactData valueForKey:@"familyName"];
NSString *middleName = [contactData valueForKey:@"middleName"];
NSString *prefix = [contactData valueForKey:@"prefix"];
NSString *suffix = [contactData valueForKey:@"suffix"];
NSString *nickname = [contactData valueForKey:@"nickname"];
NSString *company = [contactData valueForKey:@"company"];
NSString *department = [contactData valueForKey:@"department"];
NSString *jobTitle = [contactData valueForKey:@"jobTitle"];
NSString *note = [contactData valueForKey:@"note"];
ABRecordSetValue(record, kABPersonFirstNameProperty, (__bridge CFStringRef) givenName, &error);
ABRecordSetValue(record, kABPersonLastNameProperty, (__bridge CFStringRef) familyName, &error);
ABRecordSetValue(record, kABPersonMiddleNameProperty, (__bridge CFStringRef) middleName, &error);
ABRecordSetValue(record, kABPersonPrefixProperty, (__bridge CFStringRef) prefix, &error);
ABRecordSetValue(record, kABPersonSuffixProperty, (__bridge CFStringRef) suffix, &error);
ABRecordSetValue(record, kABPersonNicknameProperty, (__bridge CFStringRef) nickname, &error);
ABRecordSetValue(record, kABPersonOrganizationProperty, (__bridge CFStringRef) company, &error);
ABRecordSetValue(record, kABPersonDepartmentProperty, (__bridge CFStringRef) department, &error);
ABRecordSetValue(record, kABPersonJobTitleProperty, (__bridge CFStringRef) jobTitle, &error);
ABRecordSetValue(record, kABPersonNoteProperty, (__bridge CFStringRef) note, &error);

ABMutableMultiValueRef multiPhone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
NSArray* phoneNumbers = [contactData valueForKey:@"phoneNumbers"];
Expand Down

0 comments on commit 50ada5c

Please sign in to comment.