0

I can successfully retrieve the phone numbers associated to a contact, but for sharing purposes I need to find out which number is the contact's mobile phone number.

The type can be retrieved using the following code;

ABMultiValueRef phonesRef = ABRecordCopyValue(person, kABPersonPhoneProperty);
 if(phonesRef) {
        long count = ABMultiValueGetCount(phonesRef);
        for(int ix = 0; ix < count; ix++){
            CFStringRef typeTmp = ABMultiValueCopyLabelAtIndex(phonesRef, ix);
            CFStringRef numberRef = ABMultiValueCopyValueAtIndex(phonesRef, ix);
            CFStringRef typeRef = ABAddressBookCopyLocalizedLabel(typeTmp);


            CFStringRef typeRef = ABAddressBookCopyLocalizedLabel(typeTmp);
            NSString *phoneType = (__bridge NSString *)typeRef;
        }
}

However, how do I check if that very type is mobile? I mean sure, I could just compare the String to "mobile", but naturally that won't work in a localized environment.

Is there a constant I can compare this to?

mins
  • 6,478
  • 12
  • 56
  • 75
AlBirdie
  • 2,071
  • 1
  • 25
  • 45
  • How did you get `typeTmp`? – rmaddy Mar 31 '15 at 19:39
  • Sorry, edited the answer. – AlBirdie Mar 31 '15 at 19:42
  • 2
    So you are looking at the label assigned by the user to the phone number. It can be anything, not just "mobile" (even ignoring other languages). – rmaddy Mar 31 '15 at 19:45
  • Ah crap, you're right, didn't remember that the label can be custom as well. Any other ways to select a mobile phone number from the stack of phone numbers? – AlBirdie Mar 31 '15 at 19:47
  • No good ideas beyond looking for "mobile", "cell", "iPhone", etc. and various translations. – rmaddy Mar 31 '15 at 19:49
  • Hm... not a good solution I'm afraid. Unless iOS does some sort of magic trickery in the background to automatically select an appropriate phone number that I'm not aware of, I guess a dialog where the user has to select the phone number first. – AlBirdie Mar 31 '15 at 19:53
  • In the UK, you can look at the phone number and see if it is mobile or not. Numbers starting with 07 are mobile. – gnasher729 Mar 31 '15 at 20:42
  • @gnasher729, unfurtunately, such rules don't apply on an international scale. For instance, in germany there is no such rule of thumb. – AlBirdie Apr 01 '15 at 07:35

0 Answers0