Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Not detecting SMS when used in react-native module library #80

Open
ShashankSurvase opened this issue Jun 30, 2022 · 0 comments
Open

Not detecting SMS when used in react-native module library #80

ShashankSurvase opened this issue Jun 30, 2022 · 0 comments

Comments

@ShashankSurvase
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant