Code Monkey home page Code Monkey logo

react-native-sms-retriever's Introduction

Platform License NPM Downloads Codebeat Gitter

Cover

With the SMS Retriever API, you can perform SMS-based user verification in your Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions.



Read Phone Number Read SMS


Installation

Automatic linking (>= 0.60)

npm install --save react-native-sms-retriever

Manual linking (< 0.60)

npm install --save react-native-sms-retriever
react-native link react-native-sms-retriever

If you don't like to use react-native link, check Manual Installation Wiki Page.

Basic Usage

import SmsRetriever from 'react-native-sms-retriever';

// Get the phone number (first gif)
 _onPhoneNumberPressed = async () => {
  try {
    const phoneNumber = await SmsRetriever.requestPhoneNumber();
  } catch (error) {
    console.log(JSON.stringify(error));
  }
 };

// Get the SMS message (second gif)
_onSmsListenerPressed = async () => {
  try {
    const registered = await SmsRetriever.startSmsRetriever();
    if (registered) {
      SmsRetriever.addSmsListener(event => {
        console.log(event.message);
        SmsRetriever.removeSmsListener();
      }); 
    }
  } catch (error) {
    console.log(JSON.stringify(error));
  }
};

If you have problems to get the SMS content, check the SMS Rules Wiki Page.

Methods

Method Return Description
requestPhoneNumber() Promise<String> Obtain the user's phone number (using the hint picket).
startSmsRetriever() Promise<Boolean> Start to listen for SMS messages.
addSmsListener(event: Function) Promise<Boolean> Get the SMS content with: event.message.
removeSmsListener() Void Stop to listen for SMS messages.

Check the erros of each method on Erros Wiki Page.

Change-log

A brief summary of each React Native SMS Retriever release can be found on the releases.

License

This code is distributed under the terms and conditions of the MIT License.


Made with โค in Curitiba ๐Ÿ‡ง๐Ÿ‡ท

react-native-sms-retriever's People

Contributors

sorokin0andrey avatar gitter-badger avatar

Watchers

James Cloos 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.