Allows you to listen for incoming SMS messages using React Native
Java JavaScript
Switch branches/tags
Nothing to show
Clone or download
CentaurWarchief Merge pull request #27 from adrianolrocha/master
Add support to android build tools 25.0.0
Latest commit dc9a8b9 Dec 1, 2017

react-native-android-sms-listener react-native-android-sms-listener

An utility that allows you to listen for incoming SMS messages.


import SmsListener from 'react-native-android-sms-listener'

SmsListener.addListener(message => {

The contents of message object will be:

  originatingAddress: string,
  body: string

SmsListener#addListener returns a CancellableSubscription so if you want to stop listening for incoming SMS messages you can simply .remove it:

let subscription = SmsListener.addListener(...)

Example of using it for verification purposes:

...and if in your sign up process you have the phone number verification step which is done by sending a code via SMS to the specified phone, you might want to verify it automatically when the user receive it — pretty much like what Telegram or WhatsApp does:

let subscription = SmsListener.addListener(message => {
  let verificationCodeRegex = /Your verification code: ([\d]{6})/

  if (verificationCodeRegex.test(message.body)) {
    let verificationCode = message.body.match(verificationCodeRegex)[1]

    ).then(verifiedSuccessfully => {
      if (verifiedSuccessfully) {

      if (__DEV__) {
          'Failed to verify phone `%s` using code `%s`',

If you're using Twilio or a similar third-party messaging service which you have a fixed phone number to deliver messages you might want to ensure that the message comes from your service by checking message.originatingAddress.


$ npm install --save react-native-android-sms-listener
$ react-native link react-native-android-sms-listener

Manual Installation

For a manual installation, all you need to do to use this so-called utility is:


include ':react-native-android-sms-listener'
project(':react-native-android-sms-listener').projectDir = new File(rootProject.projectDir,'../node_modules/react-native-android-sms-listener/android')


dependencies {
  compile project(':react-native-android-sms-listener')
  // (...)

import com.centaurwarchief.smslistener.SmsListenerPackage;
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new SmsListenerPackage()
    // (...)