Monday, 15 September 2014

ios - App: use address book to find friends::: How to deal with country codes -



ios - App: use address book to find friends::: How to deal with country codes -

i working on social network. need add together "find-friends" feature based on users' phone number , address book (like whatsapp , others).

the app developing available globally , wondering how others deal problem of predials , country codes. of course of study find way around sure relatively mutual challenge associated feature. problem is, people save numbers country code , people don't. need 2 versions of phone number in database?

what think doing:

1) user registers number , types in country code , rest of number separately (two text fields). there 2 separate columns in database. 1 whole number including country code , number excluding country code.

2) user looks friends via address book. in php, each number checked , ones start "00" compared against numbers in column of international numbers. vice versa, ones don't start "00" compared against number without country code. way users can find friends irrespective of how saved number.

i appreciate help, links, advice or direction. looking best practice approaches.

thanks!

you can format local country phone number international phone number using library libphonenumber. utilize big info of phones format , country codes.

and search friends international phone number.

example of usage:

nserror* error = nil; //parse local phone number using country code ctcarrier nbphonenumber * phonenumberobject = [[nbphonenumberutil sharedinstance] parsewithphonecarrierregion: phonenumber error: &error]; if(error) { //this if no ctcarrier info. maybe ipod, iphone or ipad without sim error = nil; //you may set there way user country code, or utilize default(russia in example) phonenumberobject = [[nbphonenumberutil sharedinstance] parse: phonenumber defaultregion: @"ru" error: &error]; } nsstring* formattedinternationalphonenumber; if(!error) { formattedinternationalphonenumber = [[nbphonenumberutil sharedinstance] format: phonenumberobject numberformat: nbephonenumberformate164 error: &error]; }

ios server-side

No comments:

Post a Comment