cordova plugin add cordova-plugin-sms-retriever-api
The cordova plugin for Android that integrates the Google's SMS retriever api to read SMS without asking READ_SMS permission. For more information click here.
var smsRetriever = window.cordova && window.cordova.plugin && window.cordova.plugin.smsretriever;
if(typeof smsRetriever !== 'undefined') {
smsRetriever.startSmsRetriever(function(message){
//you receive the SMS here, if you construct it at backend as per the instructions
// Now you can take the verification code from the message and attach it to the input box in your convinient way.
},function(errMsg){
if(errMsg === 'Timed out'){
//Play services unable to retrieve the SMS to your app for one of these reasons
//1. SMS received but not constructed properly (Something wrong in your App's hashstring
//2. SMS not received from last 5 minutes.
}else{
//Failed to start retriever listner
}
});
}
You need to be cautious while generating the hashstring for your application as keytool generate the hashstring even your command has some invalid values
The invalid values can be aliasname/keystorename/packagename.