diff --git a/src/Contacts/Contact.h b/src/Contacts/Contact.h index 6ab69dbab..2b4d2ba22 100644 --- a/src/Contacts/Contact.h +++ b/src/Contacts/Contact.h @@ -16,6 +16,9 @@ typedef NS_ENUM(NSUInteger, OWSPhoneNumberType) { OWSPhoneNumberTypeWorkFAX, OWSPhoneNumberTypeOtherFAX, OWSPhoneNumberTypePager, + OWSPhoneNumberTypeHome, + OWSPhoneNumberTypeWork, + OWSPhoneNumberTypeOther }; /** diff --git a/src/Contacts/Contact.m b/src/Contacts/Contact.m index cfb3479a7..9d1a695e5 100644 --- a/src/Contacts/Contact.m +++ b/src/Contacts/Contact.m @@ -72,10 +72,14 @@ NS_ASSUME_NONNULL_BEGIN if ([phoneNumberField.value isKindOfClass:[CNPhoneNumber class]]) { CNPhoneNumber *phoneNumber = (CNPhoneNumber *)phoneNumberField.value; [phoneNumbers addObject:phoneNumber.stringValue]; - if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberMobile]) { - phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeMobile); + if ([phoneNumberField.label isEqualToString:CNLabelHome]) { + phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeHome); + } else if ([phoneNumberField.label isEqualToString:CNLabelWork]) { + phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeWork); } else if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberiPhone]) { phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeIPhone); + } else if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberMobile]) { + phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeMobile); } else if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberMain]) { phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeMain); } else if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberHomeFax]) { @@ -86,7 +90,13 @@ NS_ASSUME_NONNULL_BEGIN phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeOtherFAX); } else if ([phoneNumberField.label isEqualToString:CNLabelPhoneNumberPager]) { phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypePager); + } else if ([phoneNumberField.label isEqualToString:CNLabelOther]) { + phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeOther); } else { + // TODO this should only be hit if the user has a custom label, which ideally we'd expose rather than + // unknown. I think the thing to do is to get rid of OWSPhoneNumberType*, and simply localize the label + // in this method - uising the custom label when available. + // Maybe that means adding a "label" to PhoneNumber class and parsing the numbers in this class. phoneNumberTypeMap[phoneNumber.stringValue] = @(OWSPhoneNumberTypeUnknown); } }