Library to read incoming SMS in Android for Expo (React Native)

Overview

react-native-expo-read-sms

Maintainers

maniac-tech Active maintainer

Installation

Install this in your managed Expo project by running this command:

$ npm install @maniac-tech/react-native-expo-read-sms --save

Usage

  1. Import the startReadSMS function after installation

    import { startReadSMS } from "@maniac-tech/react-native-expo-read-sms";

  2. Pass Success and Error callbacks startReadSMS(successCallbackFn, errorCallbackFn)

  3. Everytime an SMS has been received successCallbackFn will be called with the sms

Methods

Method name Description Params Returns
checkIfHasSMSPermission Function which checks if the application has READ_SMS and RECEIVE_SMS permissions - { hasReceiveSmsPermission: true/false, hasReadSmsPermission: true/false }
requestReadSMSPermission Requests READ_SMS and RECEIVE_SMS permission, if missing - Returns true if granted, and false otherwise
startReadSMS Starts listening for incoming messages. Note: SMS Permissions should be present. callback fn Incoming message body

Important Note:

Ensure your app has READ_SMS, and RECEIVE_SMS, failing which you'll receive error on calling the function

Support

Tested on Expo SDK v44 & v45, and Node JS v14

License

MIT

Comments
  • Bug at installation

    Bug at installation

    Describe the bug when i try to install package

    
    Installing 1 other package using npm.
    > npm install --save @maniac-tech/react-native-expo-read-sms
    npm ERR! code ERESOLVE
    npm ERR! ERESOLVE unable to resolve dependency tree
    npm ERR!
    npm ERR! While resolving: [email protected]
    npm ERR! Found: [email protected]
    npm ERR! node_modules/react-native
    npm ERR!   react-native@"0.70.5" from the root project
    npm ERR!
    npm ERR! Could not resolve dependency:
    npm ERR! peer react-native@"^0.41.2" from @maniac-tech/[email protected]
    npm ERR! node_modules/@maniac-tech/react-native-expo-read-sms
    npm ERR!   @maniac-tech/react-native-expo-read-sms@"*" from the root project
    npm ERR!
    npm ERR! Fix the upstream dependency conflict, or retry
    npm ERR! this command with --force, or --legacy-peer-deps
    npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
    npm ERR!
    npm ERR! See C:\Users\kotsh\AppData\Local\npm-cache\eresolve-report.txt for a full report.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\kotsh\AppData\Local\npm-cache\_logs\2022-11-20T12_45_23_492Z-debug.log
    
    

    expo version "expo": "~47.0.6", "react": "18.1.0", "react-native": "0.70.5"

    bug good first issue 
    opened by kotsh23 7
  • Bug while init

    Bug while init

    Describe the bug i'm using expo 45 built dev apk by eas build -p android --profile development installed on real device

    App.js

    import { StatusBar } from "expo-status-bar";
    import { StyleSheet, Text, View } from "react-native";
    import {
      startReadSMS,
      checkIfHasSMSPermission,
      requestReadSMSPermission,
    } from "@maniac-tech/react-native-expo-read-sms";
    import { useEffect } from "react";
    
    export default function App() {
      useEffect(() => {
        if (checkIfHasSMSPermission) read();
        // requestReadSMSPermission();
        return () => {};
      }, []);
    
      async function read() {
        await startReadSMS(successCallbackFn);
      }
      async function successCallbackFn(status, sms, error) {
        console.log("successCallbackFn", status, sms, error);
      }
    
      return (
        <View style={styles.container}>
          <Text>Open up App.js to start working on your app!</Text>
          <StatusBar style="auto" />
        </View>
      );
    }
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: "#fff",
        alignItems: "center",
        justifyContent: "center",
      },
    });
    
    

    error i get

    `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
    at node_modules\expo\build\environment\react-native-logs.fx.js:18:22 in warn
    at node_modules\react-native\Libraries\EventEmitter\NativeEventEmitter.js:67:20 in constructor
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:463:12 in __invokeCallback
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:125:27 in __guard$argument_0
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:368:10 in __guard   
    at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:124:16 in invokeCallbackAndReturnFlushedQueue
    
    bug good first issue 
    opened by kotsh23 5
  • Can see warnings around NativeEventEmitter in console

    Can see warnings around NativeEventEmitter in console

    Description:

    Can see the following errors when the startReadSMS function is called:

    
    WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
    WARN  `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
    
    bug good first issue 
    opened by maniac-tech 2
  • Add SMS related permissions to AndroidManifest

    Add SMS related permissions to AndroidManifest

    Description:

    At the moment, we need to manually set READ_SMS and RECEIVE_SMS permissions in the app after installing the package.

    This update handles this in two ways:

    • Added these permissions to the AndroidManifest.xml
    • Updated requestReadSMSPermission to ask the user for granting the permission via Android Native API
    enhancement 
    opened by maniac-tech 0
  • Add SMS related permissions to AndroidManifest

    Add SMS related permissions to AndroidManifest

    Description:

    At the moment, we need to manually set READ_SMS and RECEIVE_SMS permissions in the app after installing the package, can we instead get them added to the library itself ?

    opened by maniac-tech 0
  • Expose `hasPermissions` function

    Expose `hasPermissions` function

    Description:

    We have hasPermissions which checks if we have the required SMS permissions in place.

    Currently it is being used internally, but we wan it to be available outside the lib too.

    good first issue 
    opened by maniac-tech 0
  • Fluent interface for using the core library

    Fluent interface for using the core library

    Is your feature request related to a problem? Please describe. Not really a problem. Considering developer experience, the library API can be improved.

    Describe the solution you'd like

    With the fluent interface, the usage will look like this:

    import smsReader from "react-native-expo-read-sms";
    
    smsReader
      .withPermission()
      .onRead(sms => { 
        /* do something with SMS string */ 
        smsReader.stop()
      })
      .onFail(error => { 
        /* do something with error; maybe stop reading */ 
      })
    

    Describe alternatives you've considered

    Support for Config

    See notes in context about supporting config that goes with auto stop mechanism. In that case, the signature of the interface changes:

    smsReader() // without config
      .withPermission()
      .onRead(...)
      .onFail(...)
    
    smsReader( { maxOnReads: 5, stopOnFail: false } )
      .withPermission()
      .onRead(...)
      .onFail(...)
    

    Stop on failure

    We can have implicit stop in case of failure so that the library user doesn't have to call stop inside onFail.

    Additional context

    • In the fluent interface, the function withPermission() will ask for permission if not given already. If the user denies the permission, onRead will not be called.
    • As onRead and onFailure may be called multiple times, it's the user's responsibility to call stop whenever done. We can have an implicit limit on how many times onRead can be called. So that way even if the user forgets to call stop; we can stop listening whenever the counter completes. This counter mechanism can also allow (optional) configuration. Ideally that we can take as a param in the reader function: smsReader({ maxOnReads: 10 }). If the optional config is not provided, then the user will be smsReader()
    opened by ashgkwd 0
  • Update `requestReadSMSPermission` return value in Readme

    Update `requestReadSMSPermission` return value in Readme

    Describe the bug The documentation states that requestReadSMSPermission returns a boolean which is not the case

    To Reproduce Steps to reproduce the behavior:

    1. call requestReadSMSPermission without passing explicit SMS permission in any app

    Expected behavior It should return boolean

    Screenshots N/A

    Desktop (please complete the following information):

    • Platform agnostic

    Smartphone (please complete the following information):

    • Platform agnostic

    Additional context N/A

    documentation good first issue hacktoberfest hacktoberfest2022 
    opened by maniac-tech 0
  • Update Readme with desc

    Update Readme with desc

    Is your feature request related to a problem? Please describe. No

    Describe the solution you'd like Add a simple Description in the read me

    Describe alternatives you've considered N/A

    Additional context N/A

    documentation good first issue hacktoberfest hacktoberfest2022 
    opened by maniac-tech 0
Releases(v1.0.12)
Owner
Abhishek Jain
Front-End Developer. Mumbai, India.
Abhishek Jain
React-native-user-interface - Change React Native userinterface at runtime

react-native-user-interface change RN userinterface at runtime. Installation npm

Ahmed Eid 0 Jan 11, 2022
Self hosted read and to-read list book tracker

JELU Official documentation Like Jelu or find it useful ? Offer me a coffee ☕ Purpose This app main purpose is to track what you have read, what you a

null 181 Dec 28, 2022
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bartłomiej Klocek 60 Dec 29, 2022
Simple library to decompress files .zip, .rar, .cbz, .cbr in React Native.

Uncompress React Native Simple library to decompress files .zip, .rar, .cbz and .cbr in React Native. Installation yarn add uncompress-react-native o

Adriano Souza Costa 40 Nov 24, 2022
Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

null 7 Sep 7, 2022
A 2020s compatible React Native keyboard avoiding view for Android and iOS that just works.

react-native-keyboard-shift Example Snack coming soon Until then: Clone this repo: git clone https://github.com/FullStackCraft/react-native-keyboard-s

Full Stack Craft 66 Aug 16, 2022
A demo for Android font typeface support in React Native!

A Step-by-step Guide to a Consistent Multi-Platform Font Typeface Experience in React Native Goal Be able to use font typeface modifiers such as fontW

Jules Sam. Randolph 53 Dec 23, 2022
🚀 React Native Segmented Control, Pure Javascript for iOS and Android

Installation Add the dependency: npm i react-native-segmented-control-2 Peer Dependencies Zero Dependency ?? Usage Import import SegmentedControl from

FreakyCoder 11 Nov 10, 2022
An Animated Scrolling View for React Native applications, supported on both iOS and Android

react-native-focused-scroll An Animated Scrolling View for React Native applications, supported on both iOS and Android Preview react-native-focus-scr

Fatemeh Marzoughi (Saba) 3 Aug 12, 2022
GeckoView implementation on android for React Native.

react-native-geckoview A fully functional implementation of GeckoView on android for react native. The component supports two-way messaging similar to

Ammar Ahmed 7 Nov 24, 2022
A react native interface for integrating payments using PayPal

react-native-paypal Getting started Installation npm install react-native-paypal Android Specific Add this to your build.gradle maven { url "https:

eKreative 14 Sep 25, 2022
Make SIP calls from react-native using Linphone SDK

react-native-sip Make SIP calls from react-native using Linphone SDK Installation npm install react-native-sip Usage import { multiply } from "react-n

Woonivers 2 Jun 30, 2022
A framework for building native applications using React

React Native Learn once, write anywhere: Build mobile apps with React. Getting Started · Learn the Basics · Showcase · Contribute · Community · Suppor

Meta 106.9k Jan 8, 2023
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

NativeScript 22k Dec 31, 2022
Wrapper for Kustomer SDK v2.0 for react native

This is a wrapper for Kustomer v2 Sdk for react native. This implements the kust

Shivam Rawat 2 Dec 30, 2021
React Native Stone SDK Implementation (Support for both Mobile and POS versions)

react-native-stone-pos Stone Android POS Native Module Installation Stone has a private packageCloud repository, so we need to have your token before

8Sistemas 9 Dec 10, 2022
Android SMS receiver with firestore and Jetpack compose

Android SMS Receiver Android SMS receiver with firestore and Jetpack compose App

Hakan Meral 2 Sep 14, 2022
an android app to send private secret SMS while terrorist Islamic republic of Iran banned internet access in Iran.

Mahsa An android application which is designed to deliver safe and encrypted messages using SMS while Islamic republic of Iran banned Iranian people a

null 3 Sep 22, 2022