React-Native SMS检索器无法按预期工作

问题描述

我正在使用React Native应用程序-sms-retriever API来自动读取SMS以从消息中检索OTP以下文章https://github.com/Bruno-Furtado/react-native-sms-retriever

_onSmsListenerpressed = async () => {
  alert('waiting for SMS')
  try {
    const registered = await SmsRetriever.startSmsRetriever();
    if (registered) {
      SmsRetriever.addSmsListener(event => {
        console.log(event.message);
        alert(event.message);
        this.setState({message:event.message});
        SmsRetriever.removeSmsListener();
      }); 
    }
  } catch (error) {
    console.log(JSON.stringify(error));
  }
};

我正在Android设备上运行 当我按下调用上述消息的按钮时,它应该开始收听 但是,当收到一条短信时,它不会发出短信提示 代码有什么问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)