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

svujldwt  于 2024-01-09  发布在  iOS
关注(0)|答案(2)|浏览(242)

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

  1. void _launchEmail() async {
  2. String email = Uri.encodeComponent("");
  3. String productTitle =
  4. _catalogStore.summaryInfo?.data?[widget.productIndex].title ?? "";
  5. String productId =
  6. _catalogStore.summaryInfo?.data?[widget.productIndex].id ?? "";
  7. String subject = Uri.encodeComponent(
  8. "mpo_product".tr() + " - " + productTitle + "($productId)");
  9. String body = Uri.encodeComponent("");
  10. Uri mail = Uri.parse("mailto:$email?subject=$subject&body=$body");
  11. try {
  12. await launchUrl(mail);
  13. } catch (e) {
  14. ToastUtil.show(
  15. ToastDecorator(
  16. isSuccess: false,
  17. msg: "something_went_wrong".tr() + "\n" + e.toString()),
  18. context,
  19. gravity: ToastGravity.bottom);
  20. }
  21. }

字符串
问题可能是什么?

zxlwwiss

zxlwwiss1#

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

  1. <key>LSApplicationQueriesSchemes</key>
  2. <array>
  3. <string>mailto</string>
  4. </array>

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

  1. final Uri params = Uri(
  2. scheme: 'mailto',
  3. path: '[email protected]',
  4. query: 'subject=Subject&body=Body Content', //add subject and body here
  5. );
  6. var url = params.toString();
  7. if (await canLaunch(url)) {
  8. await launch(url);
  9. } else {
  10. throw 'Could not launch $url';
  11. }

展开查看全部
t2a7ltrp

t2a7ltrp2#

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

相关问题