ios - How can I convert a local phone number to the international format in an iPhone app? -


i developing iphone app. @ 1 point, user types phone numbers. these can in format, international or local. local format 514-123-4567 (or worse, 123-4567), there way convert local phone numbers international format (e.164): +15141234567? means finding out country (and perhaps region too, if possible).

one way require user enter phone numbers using international format, or select country she's in. if can avoid that, think more user friendly.

i avoid asking user authorization geolocate her: lot of users refuse geolocation.

ideally, country , region of own phone number. or perhaps current carrier's country (in case user roaming in country hers).

but if installed app on ipod or ipad without sim card? maybe use locale? or try geolocate ip address?

any better ideas?

  1. for "converting" phone numbers - have example here: stphoneformatter

  2. you can use nslocale determine how localize customer - not allays determine user (locale , language both user-configurable). if want find out country phone in right now, use geolocation.

here nslocale example countrycode/country:

nslocale *locale = [nslocale currentlocale]; nsstring *countrycode = [locale objectforkey: nslocalecountrycode]; nsstring *country = [locale displaynameforkey: nslocalecountrycode value: countrycode];   

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -