I'm very new to ionic and cordova. I want to get user's phone number somehow, is it possible? I'm trying to create number registration for my app. When user opens an app the very first time he is asked to enter a code that he gets via text message. It's similar to viber. The first view contains a button 'Send me a code', and the next view has a form 'Enter code:' and a button 'Log me in'.
I think this plugin will full fill your needs (https://github.com/vliesaputra/DeviceInformationPlugin). It will give the following data
1.Your unique Device ID
2.Phone Number (if it is stored in your SIM card)
3.Country ISO of your phone network provider
4.Name of your network provider
5.Your SIM Card Serial number
6.Country ISO of your SIM card 7.Name of your SIM card mobile operator
8.E-mail/Phone number used by apps listed in your Settings > Accounts & Sync list
Here is sample code
var deviceInfo = cordova.require("cordova/plugin/DeviceInformation");
deviceInfo.get(function(result) {
//fetch the device data
console.log("result = " + result);
}, function() {
console.log("error");
});
Even though this is possible, it isn't really that related to Cordova or Ionic. What you want to do is to have back-end server which handles all other parts than collecting the phone number and the code after it. These both are actually handled by your back-end server. The flow would look something like this: