【问题标题】:using url_launcher to send a message to Telegram from Flutter app使用 url_launcher 从 Flutter 应用程序向 Telegram 发送消息
【发布时间】:2022-10-20 06:23:04
【问题描述】:

我已经使用此代码使用带有 url_launcher 的颤振向 WhatsApp 发送消息,

void sendCodeByWhatsApp({
    required int phone,
    required String message,
  }) async {
    String url() {
      if (Platform.isAndroid) {
        return "whatsapp://send?phone=$phone&text=${Uri.parse(message)}";
      } else {
        return "https://wa.me/$phone?text=${Uri.parse(message)}";
      }
    }
    if (await canLaunchUrl(Uri.parse(url()))) {
      print("https://wa.me/$phone/?text=$message");
      await launchUrl(Uri.parse(url()));
    } else {
      throw 'Could not launch ${url()}';
    }
  }

例如,如何编辑它以向 Telegram 或 viber 发送消息?

【问题讨论】:

  • 对于电报,您可以尝试 t.me/yourusername
  • 它应该是电话号码而不是用户名?

标签: flutter whatsapp telegram-api url-launcher


【解决方案1】:

试试这个。 https://telegram.me/905555555555 有效。顺便说一句,我没有测试所有可能性。

【讨论】:

    猜你喜欢
    • 2021-03-25
    • 2022-10-17
    • 2014-12-28
    • 1970-01-01
    • 2015-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    相关资源
    最近更新 更多