Phone Number Management
You can parse, format, and normalize phone numbers. The Tizen.PhonenumberUtils namespace is implemented with the libphonenumber open source library.
The main features of the Tizen.PhonenumberUtils namespace include:
-
Retrieving location information
You can get the location based on the phone number, region, and language.
-
Formatting phone numbers
You can format the phone number string based on the region using the dash ("-") and space (" ") characters.
-
Normalizing phone numbers
You can normalize the phone number.
Prerequisites
To enable your application to use the phone number management functionality, follow these steps:
-
To use the
GetNormalizedNumber()
method of the Tizen.PhonenumberUtils.PhonenumberUtils class, the application has to request permission by adding the following privilege to thetizen-manifest.xml
file:XMLCopy<privileges> <privilege>http://tizen.org/privilege/telephony</privilege> </privileges>
-
To use the methods and properties of the Tizen.PhonenumberUtils namespace, include it in your application:
C#Copyusing Tizen.PhonenumberUtils;
Retrieve location information
To retrieve the location from a phone number, use the GetLocationFromNumber()
method of the Tizen.PhonenumberUtils.PhonenumberUtils class. Provide the region of the phone number and the language of the returned location string as parameters, using the values defined in the Tizen.PhonenumberUtils.Region and Tizen.PhonenumberUtils.Language enumerations, respectively:
C#
Copy
var utils = new PhonenumberUtils();
var location = utils.GetLocationFromNumber("0222550114", Region.Korea, Language.English);
/// Method returns the location string "Seoul"
Format phone numbers
To format a phone number to use region-specific separators, use the GetFormattedNumber()
method of the Tizen.PhonenumberUtils.PhonenumberUtils class, which takes the region parameter as a value of the Tizen.PhonenumberUtils.Region enumeration:
C#
Copy
var utils = new PhonenumberUtils();
var formattedNumber = utils.GetFormattedNumber("0222550114", Region.Korea);
/// Method returns the formatted number string "02-2255-0114"
Normal phone numbers
To retrieve a phone number in a normalized format, use the GetNormalizedNumber()
method of the Tizen.PhonenumberUtils.PhonenumberUtils class:
C#
Copy
var utils = new PhonenumberUtils();
var normalizedNumber = utils.GetNormalizedNumber("0222550114");
/// Method returns the normalized number string "+821022550114"
Related information
- Dependencies
- Tizen 4.0 and Higher