Skip to content

Commit

Permalink
Merge pull request morenoh149#73 from donovanOng/master
Browse files Browse the repository at this point in the history
Support Company and Job Title fields
  • Loading branch information
morenoh149 authored Nov 22, 2016
2 parents a040061 + 287525c commit 862f057
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ios/RCTContacts/RCTContacts.m
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ -(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 *company = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonOrganizationProperty));
NSString *jobTitle = (__bridge_transfer NSString *)(ABRecordCopyValue(person, kABPersonJobTitleProperty));

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

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

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

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

if(!hasName){
//nameless contact, do not include in results
return nil;
Expand Down Expand Up @@ -221,9 +231,13 @@ -(void) updateRecord:(ABRecordRef)record onAddressBook:(ABAddressBookRef)address
NSString *givenName = [contactData valueForKey:@"givenName"];
NSString *familyName = [contactData valueForKey:@"familyName"];
NSString *middleName = [contactData valueForKey:@"middleName"];
NSString *company = [contactData valueForKey:@"company"];
NSString *jobTitle = [contactData valueForKey:@"jobTitle"];
ABRecordSetValue(record, kABPersonFirstNameProperty, (__bridge CFStringRef) givenName, &error);
ABRecordSetValue(record, kABPersonLastNameProperty, (__bridge CFStringRef) familyName, &error);
ABRecordSetValue(record, kABPersonMiddleNameProperty, (__bridge CFStringRef) middleName, &error);
ABRecordSetValue(record, kABPersonOrganizationProperty, (__bridge CFStringRef) company, &error);
ABRecordSetValue(record, kABPersonJobTitleProperty, (__bridge CFStringRef) jobTitle, &error);

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

0 comments on commit 862f057

Please sign in to comment.