0.3.2 • Published 8 months ago

rn-android-sms-retriever v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

rn-android-sms-retriever

A react native wrapper for the SMS User Consent API to request user consent to read a single SMS verification message. If the user consents, the API returns the text of the message, from which you can get the verification code and complete the verification process.

Installation

NPM:

npm install rn-android-sms-retriever

YARN:

yarn add rn-android-sms-retriever

Usage

import { getOtp, getSms, SMSRetrieverErrors } from 'rn-android-sms-retriever';

// Read the next SMS
const readNextSmsRequest = async () => {
  try {
    const sms = await getSms();
  } catch (e) {
    if (e.toString().includes(SMSRetrieverErrors.CONSENT_DENIED)) {
      console.log('User denied SMS read request');
    }
  }
};

// Read OTP from SMS
const readNextOtpRequest = async (otpLength) => {
  try {
    const sms = await getOTP(otpLength); //Can only read numeric OTP values
  } catch (e) {
    if (e.toString().includes(SMSRetrieverErrors.REGEX_MISMATCH)) {
        readNextOtpRequest(otpLength);
    }
  }
};

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Built by true-hamid & mustfaibra

0.3.2

8 months ago

0.3.1

8 months ago

0.3.0

8 months ago

0.2.0

9 months ago