maniac-tech/react-native-expo-read-sms

startReadSMS seems to be inactive

Closed this issue · 3 comments

Describe the bug
Attached is the code snippet, where I tried to run, I have enable the permissions through the Popup, but startReadSms isn't getting called similar to Issue #18 .

import { StatusBar } from "expo-status-bar";
import { StyleSheet, Text, View, Button } from "react-native";

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

export default function App() {
  const successHandler = (status, sms, error) => {
    console.log(status);
  };
  const errorHandler = (status, sms, error) => {
    console.log("error");
  };
  const btnHandler = async () => {
    try {
      const permissionState = await checkIfHasSMSPermission();

      if (permissionState.hasReadSmsPermission)
        await startReadSMS(successHandler, errorHandler);
    } catch (error) {
      console.log("error");
      console.log(error.message);
    }
  };

  return (
    <View style={styles.container}>
      {/* <Text>Open up App.js to start working on your app!</Text> */}
      <Button title="set sms" onPress={btnHandler} />
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
  },
});

To Reproduce
Steps to reproduce the behavior:
You can copy and paste above code in the latest expo app

Expected behavior
It should return me the latest sms received

Screenshots
image
Although the function initiates warning but doesn't return the sms as stated.

Additional context
I have enabled all the permissions, Do let me know If I am missing something.

Thanks for sharing the detailed information.

Will look into this.

I recently checked @maniac-tech , It started working fine somehow

I recently checked @maniac-tech , It started working fine somehow

Great, considering no issue here, I'm closing this here.

Feel free to reopen this in case you face it again.