Flutter url_launcher 阻止弹出窗口

发布于 2025-01-11 21:52:23 字数 724 浏览 3 评论 0原文

我想将用户从 flutter web 应用程序重定向到另一个网址。

我将 url_launcher 与以下代码一起使用:

if(await canLaunch(link)){
            await launch(link);
          }else{
            print('faild to load url');
          }

此代码在我的应用程序的其他页面中运行良好。但在其中一个页面中无法工作,并且我的浏览器中的弹出窗口被阻止

该代码在 Chrome(桌面和移动设备)上运行良好。但问题发生在 safari 上。

更新:在出现问题的页面中,我有一个 http 请求,然后启动该 url。

var url = Uri.parse(Api.completeOrder);
      var response = await http.post(url, body: {
        'token': token,
      });

      if (response.statusCode == 200) {
          if(await canLaunch(link)){
            await launch(link);
          }else{
            print('faild to load url');
          }
}

I want to redirect user from flutter web app to another url.

I use url_launcher with the following code:

if(await canLaunch(link)){
            await launch(link);
          }else{
            print('faild to load url');
          }

this code is working fine in other pages of my application. but not working in one of the pages and i get popup window blocked in my browser.

the code is working fine on chrome(desktop and mobile). but the problem occurs on safari.

update: in the page where the problem is occuring I have a http request and then launch the url.

var url = Uri.parse(Api.completeOrder);
      var response = await http.post(url, body: {
        'token': token,
      });

      if (response.statusCode == 200) {
          if(await canLaunch(link)){
            await launch(link);
          }else{
            print('faild to load url');
          }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文