Get Mobile Number in Ionic Framework : In ionic framework you can use the DeviceInformation plugin to get the information from device. Install the cordova plugin from – https://github.com/vliesaputra/DeviceInformationPlugin. Here we are going to explain the method to get information from device such as – Get phone number, SIM card serial number etc.
Get Mobile Number in Ionic Framework
Using the https://github.com/vliesaputra/DeviceInformationPlugin plugin you can get the following information –
- Your unique Device ID
- Phone Number (if it is stored in your SIM card)
- Country ISO of your phone network provider
- Network provider name
- SIM Card Serial number
- Country ISO of your SIM card
- Name of your SIM card mobile operator
- E-mail/Phone number used by apps listed in your Settings > Accounts & Sync list
Below is sample code to get device information to get the desired data from the result
Get Phone Number in Ionic Framework
var deviceInformation = cordova.require("cordova/plugin/DeviceInformation"); deviceInformation .get(function(result) { console.log("result = " + result); }, function() { console.log("error"); }); |
The above example will give you the device information such as phone number.
Note : The above plugin will work only in Android devices. It will not work on IOS platform