SenagasettiRamesh / cordova-plugin-sms-retriever-api

A cordova plugin that allows your app to read SMS by using Google's SMS Retriever API for Android devices.
1 stars 2 forks source link

cordova-plugin-sms-retriever-api

How to install?

cordova plugin add cordova-plugin-sms-retriever-api

Description

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.

Usage (Javascript)

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
        }
    });
}

Note

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.