Flutter Share电子邮件无法在带有url_launcher包的iOS上工作

svujldwt  于 5个月前  发布在  iOS
关注(0)|答案(2)|浏览(79)

我正在使用Flutter中的url_launcher插件与主题共享电子邮件,它在Android中使用此软件包工作正常,但在iOS或iPhone中没有发生任何事情。
下面我已经对功能作了同样的阐述:

void _launchEmail() async {
    String email = Uri.encodeComponent("");
    String productTitle =
        _catalogStore.summaryInfo?.data?[widget.productIndex].title ?? "";
    String productId =
        _catalogStore.summaryInfo?.data?[widget.productIndex].id ?? "";
    String subject = Uri.encodeComponent(
        "mpo_product".tr() + " - " + productTitle + "($productId)");
    String body = Uri.encodeComponent("");
    Uri mail = Uri.parse("mailto:$email?subject=$subject&body=$body");
    try {
      await launchUrl(mail);
    } catch (e) {
      ToastUtil.show(
          ToastDecorator(
              isSuccess: false,
              msg: "something_went_wrong".tr() + "\n" + e.toString()),
          context,
          gravity: ToastGravity.bottom);
    }
  }

字符串
问题可能是什么?

zxlwwiss

zxlwwiss1#

如果你想使用任何一种方式,请添加此键

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>mailto</string>
</array>

字符串
您也可以通过这种方式发送电子邮件请求

final Uri params = Uri(
  scheme: 'mailto',
  path: '[email protected]',
  query: 'subject=Subject&body=Body Content', //add subject and body here
);

var url = params.toString();
if (await canLaunch(url)) {
  await launch(url);
} else {
  throw 'Could not launch $url';
}

t2a7ltrp

t2a7ltrp2#

它不工作在模拟器,在真实的IOS设备中运行,它工作了!

相关问题