3

I have two phone numbers +17896786788 and +322657579849. I would like to retrieve only the code I.e, +1 and +322 by passing these phone number.

Is there any API avalable to get the code out of phone number?

libphonenumber gives the country code for the given country. Link: libphonenumber ios get country code for country

But I would like to get the code out of phone number.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Bhat
  • 602
  • 9
  • 24
  • Specifically, read [THIS](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Reference/CTCarrier/#//apple_ref/occ/instp/CTCarrier/isoCountryCode) – n00bProgrammer Apr 06 '15 at 11:48
  • 3
    The above link provides the country code from the carrier network. But i wanted the country code from the specified phone number. Please do not mark it as duplicate. – Bhat Apr 06 '15 at 11:53

1 Answers1

0

I spent a long time investigating this, and so far there is no way to do this on iOS.

Sure we can make a guess, and it would work in most cases, but there is always some cases where it will be difficult, let me give you a few exemples:

  • Canada and USA share the same international prefix: +1
  • Martinique is part of France, but has its own international prefix: +596
  • Taiwan can be considered part of China or not depending on the user's interpretation

And the list goes on..

Antzi
  • 12,831
  • 7
  • 48
  • 74