diff --git a/ios/RCTContacts/RCTContacts.m b/ios/RCTContacts/RCTContacts.m index 4046d599..4acdfe13 100644 --- a/ios/RCTContacts/RCTContacts.m +++ b/ios/RCTContacts/RCTContacts.m @@ -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"]; @@ -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; @@ -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]; @@ -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"];