flutter - 无法在 flutter 中使用 URL 启动程序包启动 gmail 应用程序

标签 flutter url gmail

当用户点击我的应用程序中的按钮时,我尝试启动 gmail 应用程序。 I am using the URL launcher package 。现在,我正在 Android 上进行测试,当我启动 youtube 或 Spotify 的 URL 时,应用程序就会启动。但是,当我尝试通过 gmail 网址启动 gmail 时,它不起作用。

这是我正在使用的网址:“https://mail.google.com/mail/u/0/#search/thisisasearch”。它不是启动到应用程序,而是启动到浏览器。谁能帮我解决这个问题吗?

此外,如果有人知道如何在 iOS 上实现这一点,我们将不胜感激!

最佳答案

要打开应用程序的默认邮件,您可以使用以下代码

  _sendMail() async {
    // Android and iOS
    const uri =
        'mailto:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1165746265517469707c617d743f7e6376" rel="noreferrer noopener nofollow">[email protected]</a>?subject=Greetings&body=Hello%20World';
    if (await canLaunch(uri)) {
      await launch(uri);
    } else {
      throw 'Could not launch $uri';
    }
  }

除了邮件之外,您还可以发送如下 URI 来进行不同的操作

  1. 调用电话 - '电话:+电话号码'
  2. 对于短信 - 'sms:+phonenumber'

关于flutter - 无法在 flutter 中使用 URL 启动程序包启动 gmail 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63287334/

相关文章:

gmail-api 检查有多少邮件未读且用户尚未回复

gmail - Gmail扩展程序邮件计数不起作用

dart - 键盘上方的 flutter/Dart 滚动文本字段

android - 当我将 ListView 放入列中时,我得到 "Another exception was thrown: RenderBox was not laid out"

Flutter:谷歌地图检测摄像头处于移动/不移动状态

php - 在 URL 中使用双斜杠有什么缺点吗?

url - 许多 URI 语法中 "://"的来源

flutter - 突出显示 DropdownButton 中的选定值(如 PopupMenuButton)

java - 读取 URL 的第一行文本

image - Gmail 的新图像缓存正在破坏时事通讯中的图像链接