Giter Site home page Giter Site logo

true-hamid / rn-android-sms-retriever Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 373 KB

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.

License: MIT License

Kotlin 42.71% JavaScript 8.67% Ruby 0.65% Java 29.36% TypeScript 18.61%

rn-android-sms-retriever's Introduction

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-dynamic-app-icon

YARN:

yarn add rn-dynamic-app-icon

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

rn-android-sms-retriever's People

Contributors

true-hamid avatar

Stargazers

Bogdan Georgian Alexa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.