Compare device phone numbers with a database

Asked

Viewed 71 times

0

Hello!

I am developing an app and need to buy the phone numbers of the device with a list of phones in a database, but the 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:

Number of the user: 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 with the database as do Telegram and Whatsapp? I need to create a code to handle each country individually?

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 in this way:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.