Git Product home page Git Product 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

gitter-badger avatar sorokin0andrey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-sms-retriever's Issues

Remove Listener?

In the example - once activated, the SmsListener is only removed after an Sms is received.
What if an Sms isn't received? what if the app is closed?

This could lead to potential data leak.
You should remove the listener when the component unmounts - for example, using useEffect.
The example should be updated to represent this. I think it's really important.

App crashes on iOS

Environment

  • React Native Version 62.2
  • Platform: iOS
  • Device: Simulator
  • OS Version 12
  • react-native-sms-retriever version 1.1.1
  • Xcode Version 12.3

Description

The library is working fine on Android. But trying to run it on iOS the app crashes with the following error:

Error: InternalError Metro has encountered an error: While trying to resolve module react-native-sms-retriever from file /Users/*****/src/screens/smsCodeVerification/smsCodeVerificationAndroid.js, the package /Users/****/node_modules/react-native-sms-retriever/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/*****/node_modules/react-native-sms-retriever/index.js. Indeed, none of these files exist:

  • /Users/*****/node_modules/react-native-sms-retriever/index.js(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
  • /Users/****/node_modules/react-native-sms-retriever/index.js/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)

Same issue . addSmsListner not working when i get the message.

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Multiple requestPhoneNumber

Sometimes js bundle can be reloaded / restarted (i.e. via Code-Push) without native restart. And if SmsRetriever has been started before js restarts, then we have app crash (or red screen on debug) after js restarts, when SmsRetriever tries to register second time. Already managed a GoogleApiClient with id 0

Working with Expo

Environment

  • React Native Version: 0.61.4
  • Platform: Android
  • Device: Xiaomi Redmi Note 4
  • OS Version
  • react-native-sms-retriever version: ~1.1.1
  • Devtools: n/a (using device)
  • Build Tools Version (Android only): EXPO

Description

I've installed react-native-sms-retriever with npm as in docs and I encountered below error:
"TypeError: null is not an object (evaluating 'RNSmsRetrieverModule.requestPhoneNumber')

Solution

I'm using expo-managed project so this could be probably an issue. Any way to use this package with expo?

Error in TS project

Environment

  • Expo Version : 36
  • Platform: Android
  • Device: Genymotion default android 9
  • react-native-sms-retriever version: ^1.1.1
  • Build Tools Version (Android only)

Description

Error occurs on typescript react-native expo project.
I just copied the doc example and pasted in TS project.

I tried with react native link and without it.

  useEffect(() => {
    async function onSmsListenerPressed() {
      try {
        const registered = await SmsRetriever?.startSmsRetriever()
        if (registered) {
         }
      } catch (error) {
        console.log(JSON.stringify(error))
      }
    }

    onSmsListenerPressed()
 
  }, [])

image

ty!

Can't SMS message

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Expo app crashes

Environment

  • React Native Version :0.63.3
  • React Version : 16.13.1
  • React-dom Version : 16.13.1
  • Expo Version: 39.0.4
  • Platform: Android
  • Device: Simulator
  • OS Version : API 27
    react-native-sms-retriever version: ~1.1.1
  • Devtools: Visual Studio Code
    Build Tools Version (Android only): EXPO

Description

TypeError: null is not an object (evaluating 'RNSmsRetrieverModule.requestPhoneNumber')

how to create the hash string in windows

Environment

  • React Native Version "0.59.8",
  • Platform: Android
  • Device: Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

I am trying to run the example which is being given by your team in github.everything executes fine.but when i send sms through the emulator shortcut the alert returns undefined.i understand this may be the problem with hashstring as it is required.could you please help me out on how to create the required hash string in windows sommand prompt.because when i run the commands given by you in earlier issues theirs an error 'xxd' is not recognized as an internal or external command'.thank you

App crashing issue on Android 12

Environment

  • React Native Version : 0.63.4
  • Platform: Android
  • Device: All android 12 devices
  • OS Version : Android 12 Latest
  • react-native-sms-retriever version : 1.1.1
  • Devtools: Android Studio Version : Bumblebee 2021.1.1
  • Build Tools Version

Description

When the Pop up triggers with mobile number it shows error like this

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_IMMUTABLE be specified when creating a Pendingintent. Strongly consider using FLAG_IMMUTABLE, only use FLAG MUTABLE if some functionality depends on the Pendingintent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Working Fine on Android 11 (SDK 30) not working on Android 12 (SDK 31).

Image :

SMS retriever issue

Kindly make a solution ASAP.

Doesn't seem to install correctly

Environment

  • "react-native": "0.59.5",

  • Platform: Android

  • Device: Pixel 3

  • react-native-sms-retriever version: current

  • Devtools: Android Studio Version: 3.1.2

  • Build Tools Version (Android only)

Android Studio 3.1.2
Build #AI-173.4720617, built on April 13, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.14.5

Description

I followed the installation directions. I am now seeing this error:

Screen Shot 2019-06-19 at 4 29 24 PM

How to create Hask key for Android in React Native.

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Only emits first event with redux-saga

Environment

  • React Native Version: 0.59.10
  • Platform: iOS / Android / Both: Android, obviously
  • Device: Which One / Simulator: Android Studio Simulator
  • OS Version: Android 10
  • react-native-sms-retriever version: 1.0.3
  • Devtools: Xcode Version / Android Studio Version:
    Android Studio 3.5.2
    Build #AI-191.8026.42.35.5977832, built on October 31, 2019
    JRE: 1.8.0_202-release-1483-b49-5587405 x86_64
    JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
    macOS 10.15
  • Build Tools Version (Android only): 28.0.3

Description

I'm using redux-saga eventChannel to subscribe to external events, like so

import { eventChannel } from 'redux-saga';
import { take, call } from 'redux-saga/effects';
import SmsRetriever from 'react-native-sms-retriever';


function createOnOTPChannel() {
  return eventChannel((emit) => {
    SmsRetriever.addSmsListener((event) => {
      console.log('received event in channel');
      emit(event.message);
    });

    return () => {
      console.log('removing');
      SmsRetriever.removeSmsListener();
    };
  });
}

function* watchOTP() {
  const registered = yield SmsRetriever.startSmsRetriever();
  if (registered) {
    const otpChannel = yield call(createOnOTPChannel);
    while (true) {
      const payload = yield take(otpChannel);
      console.log(payload);
    }
  }
}

export default watchOTP;

While receiving SMS, eventChannel only receives and emits the first one, others just go unnoticed. I specifically logged removing to see if there's a problem with the saga, but it seems not.

Update

Apparently, the listener itself is only capable of receiving single event, because the following code renders the same behavior:

React.useEffect(() => {
    const effect = async () => {
      const registered = await SmsRetriever.startSmsRetriever();

      if (registered) {
        SmsRetriever.addSmsListener((event) => {
          console.log('received event in App.js');
          console.log(event.message);
        });
      }
    };

    effect();

    return SmsRetriever.removeSmsListener();
  }, []);

Another update

This behavior is inconsistent. Since I wanted to always have a listener attached, I made it recursive (onEvent function):

const onEvent = (emit) => {
  SmsRetriever.addSmsListener((event) => {
    console.log('created');
    emit(event.message);
    SmsRetriever.removeSmsListener();
    console.log('removed');
    onEvent(emit);
  });

  return () => {
    SmsRetriever.removeSmsListener();
    console.log('removed from return');
  };
};

function createOnOTPChannel() {
  return eventChannel(onEvent);
}

function* watchOTP() {
  const registered = yield SmsRetriever.startSmsRetriever();

  if (registered) {
    const otpChannel = yield call(createOnOTPChannel);

    while (true) {
      const payload = yield take(otpChannel);
      console.log(payload, 'received');
      // const code = payload.split('\n')[0].split(':')[1].trim();
      // yield put(externalEvents.setOTP(code, new Date()));
    }
  }
}

export default watchOTP;

With this code, library inconsistently caught up to 3 first sms (most of the time of was one, though), rendering the following output to the console
image

Which means, that sometimes new listener was created and sometimes not. I'm not acquainted with java to find whether there's an issue with the retriever api itself or with this library.

Therefore, @Bruno-Furtado is there a way to alter this behavior or does it required to kill & register a new listener for every expected sms (which still doesn't have a consistent behavior)?

Problem attaching contact.

Environment

  • React Native Version: 0.55.4
  • Platform: Android
  • Device: One plus, Mi and emulator
  • OS Version: 6,7,8
  • react-native-sms-retriever version : 1.0.1

Description

I am using react native-sms-retriever to autofill otp and there is another place in app where I use react-native-contacts-picker to attach a contact. Now when I try to attach the contact I am unable to do so. I get error in PhoneNumberHelper.java line 158. This is because I am not using the service to getPhoneNumber. The problem is in the event listener for phone number. There should be some mechanism to add and remove this event listener.

just an inquiry

can i use this script to verify my twitter account ? , and thanks a lot

getting error while reading phone number in react native

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

{"nativeStackAndroid":[],"userInfo":null,"message":"There was an error trying to get the phone number.","code":"ACTIVITY_RESULT_NOOK_ERROR_TYPE","line":2580,"column":45,"sourceURL":"http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.autoreadsms&modulesOnly=false&runModule=true"}

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

event.message returnig undefined

Environment

  • React Native Version
  • Platform: Android
  • Device: Which One
  • 10
  • react-native-sms-retriever latest
  • Android Studio Version latest
  • Build Tools Version latest

Description

event.message returning undefined, SmsRetriever.requestPhoneNumber() works fine. Do I need to ask for premission?
My code just for testing

  try {
    const phoneNumber = await SmsRetriever.requestPhoneNumber();
    console.log("Phone number", phoneNumber);
    const registered = await SmsRetriever.startSmsRetriever();
    if (registered) {
      SmsRetriever.addSmsListener(event => {
        console.log("Message", event.message);
        SmsRetriever.removeSmsListener();
      }); 
    }
  } catch (error) {
    console.log(JSON.stringify(error));
  }
};

The Message I am sending

<#> This is a message: 163AD183
/jOH1cUoyR+K

The above hash code i got from running

keytool -exportcert -alias PlayDeploymentCert -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.trajnostnamobilnostfe `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

I got a different one from doing the steps 2-7 from https://developers.google.com/identity/sms-retriever/verify#1_construct_a_verification_message.

And a side quesiton. Will this lib work for IOS also or not?

Thanks in advance!

Already managing a GoogleAPIClient with id 0

Environment

  • React Native Version: 0.59.10
  • Platform:Android
  • Device: Infinix Hot 4
  • OS Version:6.0
  • react-native-sms-retriever version: "^1.0.3"
  • Devtools:Android Studio : 3.4.1
  • Build Tools Version : "28.0.3"

Description

  1. Create a fresh react native project,
  2. Run the command yarn add react-native-sms-retriever
  3. Run react-native link react-native-sms-retriever
  4. Run react-native run-android
  5. Launch your application
  6. Observe the modal prompt with the phone numbers on the device pop up
  7. Dismiss the modal
  8. Reload the application
  9. Observe the error message " Alreadt managing a GoogleAPIClient with id 0"

Phone Number Fetching Issue

Environment

  • React Native Version : 0.60+
  • Platform: Android
  • Device: Redmi Note 7S
  • OS Version : 9 Pie

Description

I am getting this error :

ACTIVITY_RESULT_NOOK_ERROR_TYPE

{"framesToPop":1,"nativeStackAndroid":[],"userInfo":null,"message":"There was an error trying to get the phone number.","code":"ACTIVITY_RESULT_NOOK_ERROR_TYPE","line":2130,"column":45,"sourceURL":"http://localhost:8081/index.bundle?platform=android&dev=true&minify=false"}

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

In ios

Hello there,is it working on ios????

Problem with install (application minimized)

Environment

  • react-native: "0.60.5",
  • Platform: Android
  • Device: Which One
  • react-native-sms-retriever: "^1.1.1",
  • Build Tools Version (Android only)

Description

I have problem, after install my app just show splash screen and minimized automatically

Problems generating the Hash and using the lib

Environment

  • React Native Version: 0.64.3
  • Platform: Android
  • OS Version: Fedora 35
  • react-native-sms-retriever version: 1.1.1

Description

Everyone is having problems creating the hash and using the lib and not getting any help

Solution

I finally got it after many tries

timeout error or event.message == null:
Apparently what causes this is the incorrect hash.
I found it by debugging the example app, as the repo owner provided the right hash.
I was using the tools and comparing until it was the same.

I had a lot of trouble finding the right way to hash it.
The way in the official Google doc is complicated, most (if not all) the scripts that generate the hash give a false feeling that everything is OK, it gives you a different hash depending on the information you pass,
as Password or Keystore Alias.

How I solved:
I used the following script

#!/usr/bin/env bash

error() { printf "%s\n" "$1" >&2; exit 1; }

command -v keytool &> /dev/null || error "Command 'keytool' not found"
(( $# >= 2 )) || error "Usage: $(basename "$0") <file.der | file.keystore alias> appId"

file=$1

[[ -r $file ]] || error "'$file' doesn't exist or isn't readable"
if [[ $file = *.keystore ]]; then
  keystore=$file
  alias=$2
  [[ $3 ]] || error "Missing application id argument"
  app_id=$3
elif [[ $file = *.der ]]; then
  trap 'code=$?; rm -rf -- "$tmp_folder"; exit "$code"' EXIT SIGINT SIGQUIT SIGTERM
  tmp_folder=$(mktemp -d)
  keystore=$tmp_folder/tmp.keystore
  alias=temp
  app_id=$2
  keytool -importcert -file "$file" -keystore "$keystore" -alias "$alias"
else
  error "'$file' needs to be of type *.der or *.keystore"
fi

keytool -exportcert -keystore "$keystore" -alias "$alias" | xxd -p | tr -d "[:space:]" | printf '%s %s' "$app_id" "$(cat)" | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

Save with .sh extension

Run

chmod u+x ./<name>.sh

to enable execution

mode of use

./key2.sh <caminho para .keystore> <key alias> <app package name>

Exemplo:

./key2.sh ./ps-deploy.keystore myalias br.com.example.app

Enter the store password when prompted
This will give the correct hash

Let's go to some points to be clarified

.jks signing key

Apps created with Expo can come with the .jks key
In my case I transformed the key into .keystore

To do this just copy and rename the file changing its extension from .jks to .keystore
Ex:

cp ./key.jks ./newKey.keystore

The app is signed with different keys in some modes

In debug mode the app is signed with the debug key, as per the config in /android/app/build.gradle -> buildTypes -> signingConfig
this may impact your correct hash

Google signs the app with another key when we upload it to the Play Store

We sign the app with our key to upload the AAB or APK, but it signs the app with an internally controlled key. Remember this to generate the hash!

If your app is published on the Play Store with keys being managed by Google, you must do the following:

On the Google Play Console page when we select our app after logging in, on the left side of the page we have the "Versions" category

Let's look at Versions -> Settings -> App Health

There we have the two credentials of our app (upload and deploy), let's download the deploy certificate

Now we need to generate the keystore from this certificate, for that we run the command:

keytool -importcert -file deployment_cert.der -keystore ps-deploy.keystore -alias myalias

Enter a storage password when prompted

Now that we have the correct .keystore file, we continue with the process of generating the hash.

./key2.sh ./ps-deploy.keystore myalias br.com.example.app

Remember that the emulator has a function that allows us to send sms and is very useful for testing this lib

Body of the SMS I used

<#>test body, codigo de verificacao: 0614

Sorry for translation errors, if you have something to add or contribute, please put it here. we are all learning

I don't know how to open extended controls I am using a mobile device connected by USB

Environment

  • React Native Version:0.63
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator:Moto E4
  • OS Version
  • react-native-sms-retriever version:^1.1.1
  • Devtools: Android Studio Version :4.0
  • Build Tools Version (Android only)

Description

I don't know how to open extended controls I am using a mobile device connected by USB

Solution

The second step u have received a message in extended controls and then send message receiving in mobile application

Firebase Phone Authentication and Sms Retriever

Is this working with Firebase Phone Authentication? in my case, it isn't triggering anything but I think that it's because firebase messages are in bad format which is a bit strange because both things are from google

Will addListener listens the message multiple times?

Environment

  • React Native Version - 0.61.4
  • Platform: Both
  • Device: All Physical devices
  • OS Version - android Pie
  • react-native-sms-retriever version - 1.1.1
  • Devtools: Xcode Version / Android Studio Version - Both
  • Build Tools Version (Android only)

Description

Will addListener listens the message multiple times? Im having an api call on listen but Im not removing listener after api call? Will this effect the api call?

Phone number error.

Environment

  • React Native Version
  • Platform: Android
  • Device: Samsung
  • OS Version 7
  • react-native-sms-retriever [email protected]
  • Build Tools Version (Android only)

Description

i have added this lib and run your sample code but i received an error
{"framesToPop":1,"code":"ACTIVITY_RESULT_NOOK_ERROR_TYPE"}

SMS Retriver API not working on Playstore Derived Build, But working in uploaded original build.

Environment

  • React Native Version - 0.59.5
  • Platform: Android
  • react-native-sms-retriever version - 1.0.3

Description

I worked on SMS retriever API (React Native Application Version = 0.59.5) and it worked successfully for my earlier app versions on debug mode, release mode and Play store also using package react-native-sms-retriever V-1.0.3. But last time, I updated build and SMS retriver API is stopped auto fetch message functionality. I tried to generate Hash key once again and they were same as in earlier builds. I used both commands and also AppSignatreHelper to generate hash key and both are same in the release mode and working fine. But when I updated APK in google play console it is not working.

where to store hash key generated from keystore

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Unable to retrieve SMS with correct HASH.

Environment

  • React Native Version: 0.66.3
  • Platform: Android
  • Device: All
  • OS Version : all
  • react-native-sms-retriever version: 1.1.1
  • Devtools: Visual Code
  • Build Tools Version (Android only)

Description

With the correct has generated, SMS was not detected.

Solution

I have created a fix and will create pull request with the fix.

Not working on Samsung and One plus. Unable to get mobile number on these devices

Environment

  • 0.68
  • Platform: Android
  • Device: Samsung & One Plus
  • OS Version: Latest 11
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Timeout error. Listener never returns event message from sms.

Environment

  • React Native Version: 58.3
  • Platform: Android
  • Device: Simulator
  • OS Version: 9
  • react-native-sms-retriever version
  • Devtools: Android Studio Version
  • Build Tools Version (Android only)

Description

I trigger the _onSmsListenerPressed function with a button. "const registered = await SmsRetriever.startSmsRetriever()" comes back as true. I then send a correctly formatted sms from the Extended Controls panel. After a few minutes I am greeted with "Timeout error."

The sms content never gets returned in the listener.

Solution (Edit)

Just replace com.sms_listener with your own package name.
The default -alias for the debug keystore will always be androiddebugkey

keytool -exportcert -alias androiddebugkey -keystore '~\.android\debug.keystore' | xxd -p | tr -d "[:space:]" | echo -n <<<com.sms_listener>>> cat | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

If you are using the debug keystore like me, it will ask for a password after you run the above command.
The default password is: android

A string will then be generated, something like this: gaMzAZ+vMRr

Is <#> really necessary?

Taking a look at the SMS Retriever API, it seems there is no need to add the <#> code at the start of the message. Only the app hash string is needed.

So instead of sending this SMS:

<#> Hello, your code is: 383838
3gh3k3j2k2l

You could simply send:

Hello, your code is: 383838
3gh3k3j2k2l

Which is better for user readability. What do you think?

Crash on startup iOS.

Environment

  • React Native Version 0.49
  • Platform: iBoth
  • Device: Simulator
  • OS Version: IOS 12
  • react-native-sms-retriever 1.0.1
  • Devtools: Xcode 12

Description

I'm not sure if this is a genuine issue or a mistake on my behalf, I have successfully installed and integrated the SMS retriver and tested it on android.
But now I get the following error which crashes the application on launch on IOS (simulator and device):
2019-03-06 15:49:42.386634+0200 EFGConnect[74395:1038144] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: undefined is not an object (evaluating 'i.requestPhoneNumber')', reason: 'Unhandled JS Exception: undefined is not an object (evaluating 'i.requestPh..., stack:

I can see that 'i.requestPhoneNumber' is included in ios/main.jsbundle which is causing this error.

Solution

I think excluding the plugin from IOS linking would fix this issue.

Again sorry if this is not a real issue, I just couldn't find any documentation regarding IOS.

I'm unable to retrieve the message.

_onSmsListenerPressed = async () => {
try {
const registered = await SmsRetriever.startSmsRetriever();
if (registered) {
SmsRetriever.addSmsListener(event => {
console.log(event.message);
//I am not able to get the response here event.message
SmsRetriever.removeSmsListener();
});
}
} catch (error) {

  console.log(JSON.stringify(error));
}

};

4 phone numbers giving on dialog. After clicked on button for fetching sim numbers but on dialog box 4 numbers giving me.

Environment

  • React Native Version
  • Platform: iOS / Android / Both
  • Device: Which One / Simulator
  • OS Version
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

Description

Explain what you did, what you expected to happen, and what actually happens.
Provide some code or prints if needed.

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

Getting country code along the number

Environment

  • React-Native Version: 0.63.3
  • Platform: Android
  • Mobile Model : VIVO
  • OS Version : 6.0
  • react-native-sms-retriever version: 1.1.1
  • Actual Device

Description

Getting phone number along the country code.

const phoneNumber = await SmsRetriever.requestPhoneNumber(); console.log(phoneNumber);

This console the value "+9178******21"

Would like to know if I can get only the number or is there any way to extract just phone number.

E.g: "78******21"

Can I please get the solution for this?

event.message returns timeout

Environment

  • React Native Version: 0.61.5
  • Platform: Android
  • Device: Moto G4(Plus)
  • OS Version: 7.0
  • react-native-sms-retriever version: ^1.1.1
  • Devtools: Xcode Version: 11.0 / Android Studio Version: 3.5.2
  • Build Tools Version (Android only)

Description

event.message returns {timeout: “Timeout error.”}

Code snippet

registered = await SmsRetriever.startSmsRetriever();
      if (registered) {
        SmsRetriever.addSmsListener(event => {
          const msg = event.message || '';
          console.log(msg);

Sms sent

<#>Your verification code is 1207
tt+ja/0sjDF

Un able to retrieve message in release mode react-native-sms-retriever

Inked2
This is the hash I am using for release. It is not working though. In development mode, I got the has key using react-native-otp-verify & it is working fine. I did not upload the file to the play store till now because I wanted to make whether it will work or not(I have checked with this command npx react-native run-android --variant=release).
I am using RN version: 64.0.3
react-native-sms-retriever: 1.1.1

Not detecting SMS when used in react-native module library

Environment

  • React Native Version: 0.66.3
  • Platform: Android
  • Device: All android devices / Simulator
  • OS Version: Android 11
  • react-native-sms-retriever version 1.1.1
  • Devtools: Android Studio Version - Bumblebee 2021.1.1
  • Build Tools Version (Android only) 4.2.2

Description

I am using the library as a peer dependency in my react-native module. The module hold the logic for starting the sms retriever and listening for SMS. But its not detecting the SMS.
Oddly, when the same logic is used directly in the sample app, it works as expected.
Are there any extra steps required for using the library in a module?
From the logs, I can confirm that the SmsRetriever service is started. But I am not sure if the listener is active when used in a module.

Module code for calling SmsRetriever -

const readSMS = async () => {
  try {
    const registered = await SmsRetriever.startSmsRetriever();
    console.log('registered', registered);
    if (registered) {
      await SmsRetriever.addSmsListener(onReceiveSms);
    }

    console.log(`SMS Listener Registered: ${registered}`);
  } catch (error) {
    console.log(`SMS Listener Error: ${JSON.stringify(error)}`);
  }
};

const onReceiveSms = (event: any) => {
  console.log('event', event.message);
  SmsRetriever.removeSmsListener();
};

//Button is in sample app
<Button
  title={ADD_SMS_LISTENER_TITLE}
  onPress={Registration.readSMS}
/>

Image - when sms retriever is used directly in sample app
RNSmsRetrieverSuccess

App crashs after installing package

Hello. After installing package I tried to run app on emulator and real device android and app instantly crashs without giving any error. I have such dependencies
"@react-native-community/async-storage": "^1.11.0",
"@react-native-community/checkbox": "^0.4.2",
"@react-native-community/masked-view": "^0.1.7",
"@react-native-community/netinfo": "^5.9.4",
"@react-navigation/bottom-tabs": "^5.2.2",
"@react-navigation/native": "^5.1.1",
"@react-navigation/stack": "^5.5.1",
"axios": "^0.19.2",
"jwt-decode": "^2.2.0",
"mitt": "^1.2.0",
"moment": "^2.27.0",
"native-base": "^2.13.12",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-bootsplash": "^2.2.5",
"react-native-easy-toast": "^1.2.0",
"react-native-elements": "^2.0.4",
"react-native-gesture-handler": "^1.6.1",
"react-native-gifted-chat": "^0.16.3",
"react-native-iphone-x-helper": "^1.2.1",
"react-native-keyboard-spacer": "^0.4.1",
"react-native-localization": "^2.1.6",
"react-native-maps": "0.27.1",
"react-native-masked-text": "^1.13.0",
"react-native-onesignal": "^3.9.0",
"react-native-reanimated": "^1.7.0",
"react-native-responsive-fontsize": "^0.4.3",
"react-native-responsive-screen": "^1.4.1",
"react-native-safe-area-context": "^0.7.3",
"react-native-screens": "^2.4.0",
"react-native-vector-icons": "^6.6.0",
"react-redux": "^7.2.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"

I don't know what to do next. Please help

App crashes

After installing the package and run the project, I get this error message
image
Any solution???

android app is crashing with error { Fatal Exception: java.lang.VerifyError }

  • React Native Version
  • Platform: Android
  • Device: samsung galaxy s8
  • OS Version android 9
  • react-native-sms-retriever version
  • Devtools: Xcode Version / Android Studio Version
  • Build Tools Version (Android only)

react native app is crashing with following errors. this crash is occur to prod users. we are unable to replicate this issue. thank you.

Fatal Exception: java.lang.VerifyError: Superclass androidx.core.app.e of androidx.activity.ComponentActivity is declared final (declaration of 'androidx.activity.ComponentActivity' appears in /data/app/com.brightchamps.learner-qyaTfWUR1-VmUW09V67tSA==/base.apk)
at me.furtado.smsretriever.RNSmsRetrieverModule.(RNSmsRetrieverModule.java:14)
at me.furtado.smsretriever.RNSmsRetrieverPackage.createNativeModules(RNSmsRetrieverPackage.java:26)
at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1404)
at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1375)
at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1275)
at com.facebook.react.ReactInstanceManager.access$1100(ReactInstanceManager.java:135)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1053)
at java.lang.Thread.run(Thread.java:764)

Solution

Do you know what needs to be done to address this issue? Ideally, provide a pull request with a fix.

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.