Find Country Code from Phone Number - ios

In my app , I am using phone numbers like +17896786788,+322657579849.
I would like to retrieve only the country code i.e, +1 or +322 by passing any phone number, that is I will send phone number and it will return the country code of that number.
Is there any API or anything available to get the country code from the phone number?
How can I find that?

I dont know about an API for splitting country code from a phone number,
But you can use this link to get all countries and their corresponding codes. Its a json file. You first parse all codes to an array from this json and then compare each element wth your phone number by using "range" funtion along with + symbol
Try it. U will get it.

Related

How to send numbers in User Attributes on Firebase?

I'm trying to send numbers in my Firebase application to send notification to specific users and I noticed that we can use numbers but there's only this function to send string data
FIRAnalytics.setUserPropertyString(numberOfOrders, forName: TrackingConstants.UserAttributeKeys.NumberOfOrders)
Is there an other function for sending numbers or does Firebase threat any numbers sent as a string like a number once it receives the data? I could not find any documentation on how to use numbers for User Attributes.
You can use the operators on the UserProperty just like Numbers even though it is set as a string.

Chack number from contacts is mobile or fixed line(landline) number

I wanted to have a check whether the phone number getting from the contacts is a Mobile number or a fixed line(landline) number. I have tried using the regrex but all is in vain..any help will be highly appreciable
For filtering contact by mobile number and landline you need have list of std code in database and then you can check if immediate digits after country code match std code then it's landline. You can search for such api as well.
Try : http://www.searchbug.com/api/

How to only get places having phone numbers via Foursquare api?

i am trying to implement forsquare api in my project to get nearby places, but i want the places with phone numbers only.
The following url is created when searching for some places:
https://api.foursquare.com/v2/venues/search?client_id=NUAAA4QFSP...MEW5QYULV&client_secret=FIGD...X0LQBAB&v=20131109&locale=en&categoryId=4d4b7105d754a06374d81259,4d4b7105d754a06376d81259&ll=33.85982057734948,35.55264679015678&radius=2000
The problem is the result will contains all the places corresponding to the categories I checked and within the radius 2000.
I tried to add "query", but this will only search in the result name
So how to get only the places with phone numbers?
Thank you

GET request in Rails with big count of params

I want to make some Rails API for a mobile app, and there is the following situation: my app will authorize using a phone number (like Viber / WhatsApp); also it can automatically detect which contacts from a phone book also have my app installed. If I understand right I should create some GET method to take array of numbers and return numbers of users which have been in my system already. There are no problem with GET method for me and arrays in GET params, but phone book of users can be very big, and sending all numbers in GET params is not good solution. How can I do it right? Should I divide numbers in parts and send first 10 numbers, then next 10 numbers etc? Thanks in advance.
Just use a POST request instead. You don't have to always use GET when you're searching for stuff.
You could also optimize your query string:
?ph=5551112222,5552223333...
This at least minimizes the request size. I think Rails should give you params[:ph] as an array. If not then splitting the string on a comma is just one extra line of code.

iOS formatting phone numbers from address book

My app uses the user's phone number as unique username, and it also sync all of his contacts so he can send them messages.
So, I need a way to format all the phone numbers I'm getting from the phone's address book.
I need to know for a given number:
Country code (if exists).
The number itself.
And if the number includes some international call prefix, it should be remove from the number.
So for example if I have a contact with the number
014 1 3728834122
The format should tell me that the country code is 1 and that the number is 3728834122 (I don't care about the 014 prefix)
What interesting is that the native phone address book seems to know how to format the number, I can see it while typing a new number, it added () or spaces when needed.
So my question is:
Can I query the native address book for a given number, what's his country code & number?
Does anyone knows a good library that do this kind of formatting?

Resources