Skip to content

Commit

Permalink
Add Company and Job Title
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanOng committed Jun 23, 2016
1 parent 467d552 commit 7527e61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion 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, kABPersonCompanyProperty));
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 @@ -182,7 +192,7 @@ -(NSString *) getABPersonThumbnailFilepath:(ABRecordRef) person
tempfilePath = [[NSFileManager defaultManager]
stringWithFileSystemRepresentation:template
length:strlen(template)];

tempfilePath = [tempfilePath stringByAppendingString:@".png"];

[data writeToFile:tempfilePath options:NSAtomicWrite error:&err];
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, kABPersonCompanyProperty, (__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 7527e61

Please sign in to comment.