All Projects → andreyvital → React Native Android Sms Listener

andreyvital / React Native Android Sms Listener

Licence: mit
Allows you to listen for incoming SMS messages using React Native

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to React Native Android Sms Listener

SnorkTracker
GPS IoT tracker board for scanning gps and environment information and sending this to a MQTT server via GPRS.
Stars: ✭ 38 (-86.67%)
Mutual labels:  sms
screeps notify
Send messages (SMS, Slack) from inside Screeps Scripts
Stars: ✭ 21 (-92.63%)
Mutual labels:  sms
PonyDirect
PonyDirect
Stars: ✭ 34 (-88.07%)
Mutual labels:  sms
sms
高可用短信微服务
Stars: ✭ 57 (-80%)
Mutual labels:  sms
owt
Update Version 3.1 added free SMS messaging.
Stars: ✭ 339 (+18.95%)
Mutual labels:  sms
docs
blaulichtSMS API (Schnittstellenbeschreibung)
Stars: ✭ 15 (-94.74%)
Mutual labels:  sms
jasmin-web-panel
📨 Jasmin Web Panel for Jasmin SMS Gateway
Stars: ✭ 33 (-88.42%)
Mutual labels:  sms
laravel-sms
Package for sending SMS from your Laravel app / Пакет для отправки смс из вашего приложения Laravel
Stars: ✭ 21 (-92.63%)
Mutual labels:  sms
ionic-native-sms-retriever-plugin-master
Cross-platform plugin for Cordova / PhoneGap to Retrieve SMS. Available for Android.
Stars: ✭ 16 (-94.39%)
Mutual labels:  sms
laravel-authy
Rinvex Authy is a simple wrapper for @authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 35 (-87.72%)
Mutual labels:  sms
sms
API server to send SMS using GSM modem. Written in Go
Stars: ✭ 26 (-90.88%)
Mutual labels:  sms
go sgip
This is an implementation of SGIP 1.2 for Go
Stars: ✭ 17 (-94.04%)
Mutual labels:  sms
dj-twilio-sms
Twilio SMS Integration for Django
Stars: ✭ 15 (-94.74%)
Mutual labels:  sms
vonage-node-code-snippets
NodeJS code examples for using Nexmo
Stars: ✭ 46 (-83.86%)
Mutual labels:  sms
laravel-easy-sms
overtrue/easy-sms service provider for Laravel.
Stars: ✭ 16 (-94.39%)
Mutual labels:  sms
fake-sms-notifier
Fake SMS (as email during development) Notifier Bridge
Stars: ✭ 16 (-94.39%)
Mutual labels:  sms
scoutx
ScoutX: An SMS/Voice notifier for Nightscout, and now currently working on a Wisblock powered GPS tracker with Helium as well as an accessible DIY Libre CGM solution.
Stars: ✭ 33 (-88.42%)
Mutual labels:  sms
Springboot Learn
🌹springboot常用框架整合示例,涉及多种网站监控,数据缓存,网络通信,持久层,权限管理,常用工具等
Stars: ✭ 270 (-5.26%)
Mutual labels:  sms
Clean-SmS-Forwarding
Forwarding your sms.
Stars: ✭ 88 (-69.12%)
Mutual labels:  sms
scriptbox
Script box is a full VAS application for demonstrate kannel.js, shorty and smpp usage
Stars: ✭ 19 (-93.33%)
Mutual labels:  sms

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

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

Example

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

SmsListener.addListener(message => {
  console.info(message)
})

The contents of message object will be:

{
  originatingAddress: string,
  body: string,
  timestamp: number
}

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(...)

subscription.remove()

In recent versions of Android you might also have to ask for permissions:

async function requestReadSmsPermission() {
  try {
    await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.READ_SMS,
      {
        title: "(...)",
        message: "Why you're asking for..."
      }
    );
  } catch (err) {}
}

class MyComponent extends Component {
  // ...

  componentDidMount() {
    requestReadSmsPermission();
  }

  // ...
}

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]

    YourPhoneVerificationApi.verifyPhoneNumber(
      message.originatingAddress,
      verificationCode
    ).then(verifiedSuccessfully => {
      if (verifiedSuccessfully) {
        subscription.remove()
        return
      }

      if (__DEV__) {
        console.info(
          'Failed to verify phone `%s` using code `%s`',
          message.originatingAddress,
          verificationCode
        )
      }
    })
  }
})

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.

Installation

$ 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:

android/settings.gradle

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')

android/app/build.gradle

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

MainApplication.java

import com.centaurwarchief.smslistener.SmsListenerPackage;
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new SmsListenerPackage()
    // (...)
  );
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].