Skip to main content
mobileSMS

Format phone number.

by July 24, 2020No Comments

Obtaining phone numbers from your app users and formatting them in an international standard (like E164) is often cumbersome and inaccurate, leading to poor conversions in the verification flow and limited reach among your SMS user base. And until now, creating your own number formatting system has required weeks of extra research, development, and, most importantly, maintenance.

Global apps: local phone numbers
A key aspect when building globally distributed applications is embracing local specificities such as language and date formatting to achieve good results across all markets. For phone numbers, the challenge is capturing phone numbers in a format the user is most familiar with—a local or national format—and standardizing it for use with verification or voice services. SMS.

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

You need to add a “9” between the international prefix and the mobile number, while the national prefix 15 must be removed.
In a real use case, if a user enters the following number (223) 15 123–4567, its international format equivalent would be +5492231234567
You may notice that the + sign, country code and a leading 9 have been added while the country code 15 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 our ongoing effort to make verification and communication flows in apps easier, we have now added new APIs to our verification SDKs that help app developers with phone number formatting, making it very easy to parse and display phone numbers in any iOS or Android app. 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
Using the Argentina example above, using the Sinch Verification SDK will take care of formatting the international phone number and can provide users with feedback on whether the phone number they entered is in a valid format.

Step 1:

Based on the country selected, the app can display 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 automatically knows it 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 seamless as possible, we believe these new APIs will make it easier and faster. Please share your feedback, questions, and suggestions on how to use this new feature and where it can be improved.

Leave a Reply