I try to implement auto fill otp but am not get any success am using this below code
constructor(){
document.addEventListener('onSMSArrive', function(e){
var sms = e.data;
alert("received sms "+JSON.stringify( sms ) );
if(sms.address=='HP-611773') //look for your message address
{
this.otp=sms.body.substr(0,4);
this.stopSMS();
this.verify_otp();
}
});
this.checkPermission();
}
checkPermission()
{
//alert('checkPermissionAndSend');
this.platform.ready().then(() => {
this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_SMS).then(
success => {
//if permission granted
this.receiveSMS();
},
err =>{
this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.READ_SMS).
then(success=>{
this.receiveSMS();
},
err=>{
alert("cancelled")
});
});
this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_SMS]);
});
}
receiveSMS()
{
if(SMS) SMS.startWatch(function(){
alert('watching started');
}, function(){
alert('failed to start watching');
});
}
stopSMS()
{
if(SMS) SMS.stopWatch(function(){
alert('watching stopped');
}, function(){
alert('failed to stop watching');
});
}
Please help me out am stuck on it since 3 days
Thanks in advance