【问题标题】:Unable to send SMS using telephony无法使用电话发送 SMS
【发布时间】:2022-06-22 16:55:47
【问题描述】:

我一直在尝试按照 youtube 教程 https://www.youtube.com/watch?v=X4yFdl3o1Lg 使用电话发送短信。但是,尽管添加了所需的权限,但没有发送任何消息。

  final SmsSendStatusListener listener = (SendStatus status) {
// Handle the status

 };

  final Telephony telephony = Telephony.instance;
  

  final _formKey = GlobalKey<FormState>();

    _sendSMS2() async {
       
        bool? permissionsGranted = await telephony.requestSmsPermissions;
        print(permissionsGranted);  //returns true
        bool? canSendSms = await telephony.isSmsCapable;
        print(canSendSms); //returns true
        // Get sim state
        SimState simState = await telephony.simState;
        print(simState);  //returns SimState.READY
        
        telephony.sendSms(to: "123456", message: "hello", statusListener: listener);
        
        }
      }

状态返回 sendStatus.SENT 但我没有发现任何消息正在发送。 我真的需要帮助,拜托。

【问题讨论】:

  • 控制台输出错误吗?
  • @EnviroApps 控制台上没有错误。 canSendSms 打印 true,simState 打印 SimState.READY。
  • 好的,谢谢您的信息。您是否查看了位于pub.dev/packages/telephony 的插件的文档和示例代码?此外,此软件包仅适用于 Android 顺便说一句。
  • 是的,我检查了以下链接。通过默认 SMS 应用发送 SMS 有效(telephony.sendSmsByDefaultApp(to: "1234567890", message: "Hi!");但不能直接从应用发送。我不明白为什么
  • @EnviroApps 除了使用电话直接发送短信而不通过默认短信应用程序,还有其他方法吗?

标签: flutter sms telephony


【解决方案1】:

有人知道吗,我有同样的问题,我没有找到解决方案,请帮忙,谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多