Compare device phone numbers with a database

0

Hello

I'm developing an app and need to buy phone numbers from the device with a list of phones in a database, but phone numbers can be written in different ways as described in Wikipedia :

Number structure for networks
Country Code - cc = 1 to 3 digits
Identification Code = x = 1 to 4 digits
Subscriber Number = maximum = 15 − (cc + x) = 8 to 11 digits
International public telecommunication number for networks (maximum 15 digits)

So in Brazil the phone number can be written as:

User Number: 99999-9999

Identification code + User number 67 99999-9999

Country code + Identification code + User number 55 67 99999-9999 or +55 67 99999-9999

And in other countries the phone number can be written in different ways and have different numbering patterns.

How can I buy device numbers from the database like the Telegram and Whatsapp? Do I need to create a code to handle each individual country?

    
asked by anonymous 19.12.2016 / 14:09

1 answer

1

I'm using libphonenumber for Android and libPhoneNumber-iOS for Swift and they work very well.

To get the area code of a number I use getLengthOfGeographicalAreaCode like this:

String nationalSignificantNumber = phoneUtil.getNationalSignificantNumber(number);
int nationalDestinationCodeLength = phoneUtil.getLengthOfNationalDestinationCode(number);

if (nationalDestinationCodeLength > 0) {
nationalDestinationCode = nationalSignificantNumber.substring(0, nationalDestinationCodeLength);
}

To buy two numbers I use isNumberMatch

    
29.12.2016 / 15:11