Skip to main content
mobileSMS

Format phone number.

by July 24, 2020No Comments

Getting a phone number from your app users and formatting them to an international standard (such as E164) is often cumbersome and inaccurate; leading to poor conversion in the verification flow and low reach of your user base via SMS. And until now, creating your own number formatting system has required extra weeks of research, development, and most importantly, maintenance.

Global apps: local phone numbers
A key aspect when building globally distributed applications is to embrace local specifics such as language and date formatting to perform well in all markets. For phone numbers, the challenge is to capture phone numbers in a format the user is most familiar with - a local or national format - and standardize it for use with verification or voice services or SMS.

Let's take an example: in Argentina, the transformation of a local phone number into the international format should follow this rule:

A “9” must be added between the country code and the mobile number, while the country code 15 must be removed
In a real use case, if a user enters the following number (223) 15 123–4567, its equivalent international format would be +5492231234567
You can see that the + sign, the country code and an initial 9 have been added while the 15 country code has been removed
These are not uncommon and many countries are subject to custom rules, making it difficult to efficiently format phone numbers in all areas.

Sinch API for phone number formatting
In an ongoing effort to make verification and communication flows in apps easier and easier, we have now added new APIs to our Verification SDKs that help app developers with phone number formatting, which makes parsing very easy. and viewing phone numbers in any iOS app or Android . Features Include:

List of regions and phone codes - automatically populates a table view with a list of countries and their phone area codes
Phone Format Example - Displays a sample phone number for any selected country
Formatting As You Type: Validates a text field in real time and provides visual feedback to the user
E164 Conversion: Convert a local phone number to an international phone number by following each specific country rule
With the Argentina example above, using the Sinch Verification SDK will take care of formatting the international phone number and can provide users with feedback that the phone number entered is in a valid format.

Step 1:

based on the selected country, the app can view and sample the number to better understand the expected format

Step 2:

when the phone number is not in a valid format, the app can immediately display this information to the user

Step 3:

when the phone number is entered correctly, the user knows it automatically and can proceed with a verification
We know that formatting phone numbers can be a real hassle in some countries and as part of our mission to make the phone number verification process as smooth as possible, we believe these new APIs will make this process easier and faster. Please let us know your feedback, questions and suggestions on how to use this new feature and where it can be improved.

Leave a Reply