Giter VIP home page Giter VIP logo

react-native-sms-retriever-android's Introduction

react-native-sms-retriever-android npm version

Getting started

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

Mostly automatic installation

$ react-native link react-native-sms-retriever-android

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.bhavesh.smsretriever.RNSmsRetrieverAndroidPackage; to the imports at the top of the file
  • Add new RNSmsRetrieverAndroidPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-sms-retriever-android'
    project(':react-native-sms-retriever-android').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-sms-retriever-android/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-sms-retriever-android')
    

Usage

import RNSmsRetrieverAndroid from 'react-native-sms-retriever-android';

/*
 * Returns app signature array, which is used to identify the SMS sent from your server
 * callback: (optional) to receive signature array
 */
const signatureArray = await RNSmsRetrieverAndroid.getAppSignature(callback);

/*
 * Subscribe to listen for incoming SMS
 * listener: ({ message: string, error: string, code: number}) => void
 * callback: (optional) to check if subscription was successful or not
 */
const subscription = await RNSmsRetrieverAndroid.retrieveSMS(listener, callback);

// To remove subscription
subscription.remove();

Note

  1. App signature will vary for debug and release builds

  2. Subscription will be valid for one time only. To listen for next sms, subscribe again

  3. Subscription is valid for 5 minutes. After that listener will receive timeout error

  4. Example SMS: "<#> Your ExampleApp code is: 123ABC78 FA+9qCX9VSu"

    FA+9qCX9VSu => This is your app signature

react-native-sms-retriever-android's People

Contributors

kkbhav 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.