Flutter 应用程序在启动 URL(例如 URL Launcher)后在模拟器中挂起

问题描述 投票:0回答:1

我正在开发一个 Flutter 应用程序并使用 url_launcher 包来打开 URL。该应用程序在 Android 和旧版本的 iOS 上运行良好,但当我使用模拟器在 iOS 18 上测试它时,该应用程序在启动 URL 后挂起。

这是我用来启动 URL 的代码:

Future<void> _launchURL(Uri url) async {
  if (await canLaunchUrl(url)) {
    await launchUrl(url);
  } else {
    throw 'Could not launch $url';
  }
}

URL 正确启动,但应用程序立即变得无响应,我必须停止模拟器才能继续。此问题仅出现在 iOS 18 上;它在旧版本上运行良好。

重现步骤:

1.  Install the url_launcher package in the Flutter app.
2.  Use the code above to launch a URL.
3.  Run the app on an iOS 18 simulator.
4.  Attempt to launch a URL.

预期行为: URL 应打开,并且应用程序应保持响应。

实际行为: URL 启动,但应用程序随后挂起并变得无响应。

环境:

•   Flutter: 3.24.3 (Stable branch)
•   iOS Simulator: iOS 18
•   url_launcher: ^6.3.0

还有其他人遇到过这个问题吗?任何解决该问题的建议将不胜感激!

PS:当我使用具有 Google 功能的标志(还启动应用程序内浏览器)和具有 PayPal 功能的 Stripe 结帐时,该应用程序也会挂起。

ios flutter inappbrowser url-launcher ios18
1个回答
0
投票

更新 url_launcher 包,

Future<void> _launchURL(Uri url) async {
  if (await canLaunchUrl(url)) {
    await launchUrl(
      url,
      mode: LaunchMode.externalApplication,
    );
  } else {
    throw 'Could not launch $url';
  }
}

试试这个,

© www.soinside.com 2019 - 2024. All rights reserved.