I am developing an iPhone app. At one point, the user types phone numbers. These can be in any format, international or local. Local format would be something like 514-123-4567
(or worse, just 123-4567
), is there a way to convert local phone numbers to the international format (E.164): +15141234567
? This means finding out what the country is (and perhaps the region too, if possible).
One way would be to require the user to always enter phone numbers using the international format, or to select the country she's in. But if I can avoid that, I think it would be more user friendly.
I would also like to avoid asking the user for the authorization to geolocate her: a lot of users refuse geolocation.
Ideally, I would like to get the country and region of her own phone number. Or perhaps the current carrier's country (in case the user is roaming in another country than hers).
But what if she installed the app on an iPod or iPad without a SIM card? Maybe I could use the locale? Or I could try to geolocate the IP address?
Any better ideas?