不允许启动自定义协议,因为需要用户手势

发布于 2025-01-16 06:36:59 字数 1107 浏览 2 评论 0原文

我需要运行我的自定义协议两次,但第二次不起作用,我收到此错误(不允许启动“cutomProtocol”,因为需要用户手势。)我尝试找到解决方案但我没有找到任何!

chrome、firefox 和 Edge 也有同样的问题。

在此处输入图像描述

我需要看到此弹出窗口两次 在此处输入图像描述

window.location.href = 'my-protocol://${base64}';

customProtocolVerify(
      `my-protocol://${base64}`,
      () => {
        // successCb: Callback function which gets called when custom protocol is found.
        console.log('My protocol found and opened the file successfully..');
      },
      () => {
        // failCb: Callback function which gets called when custom protocol not found.
        console.log('My protocol not found.');
      }
    );

尝试了这两个,但没有成功

澄清

我有一个自定义协议。

我的场景:

  1. 检查它是否安装成功(我正在使用 customProtocolVerify 方法),如果找到协议,该方法就会启动
  2. ,运行一些 API
  3. 再次启动协议

我的问题:

第 3 步不起作用,我在控制台上出现错误,显示“不允许启动...”,当然我看不到打开协议的弹出窗口。

我请求帮助以使第 3 步顺利进行

I need to run my custom protocol twice but it doesn't work the second time, I got this error ( Not allowed to launch 'cutomProtocol' because user gesture is required. ) I tried to find a solution but I did not find any!

Same problem with chrome, firefox and edge.

enter image description here

I need to see this popup twice
enter image description here

window.location.href = 'my-protocol://${base64}';

and

customProtocolVerify(
      `my-protocol://${base64}`,
      () => {
        // successCb: Callback function which gets called when custom protocol is found.
        console.log('My protocol found and opened the file successfully..');
      },
      () => {
        // failCb: Callback function which gets called when custom protocol not found.
        console.log('My protocol not found.');
      }
    );

I tried with these two and didn't work

Clarification

I have a custom protocol.

My scenario:

  1. check if it's installed successfully (I'm using customProtocolVerify method) and that method makes the launch if the protocol is found
  2. run some APIs
  3. launch the protocol again

My problem:

Step 3 doesn't work, I have the error on the console that says " Not allowed to launch... " and of course I can't see my popup to open my protocol.

I'm asking for help to make step 3 work

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2025-01-23 06:36:59

绕过此“错误”的唯一方法是通过显示 OK 警报或某种用户确认框来询问用户两次(或循环)。

我的解决方案:

OpenLinkInExternalApp(Link);
alerty.alert('', { title: '', okLabel: 'Open Link'  }, function () {
    OpenLinkInExternalApp(Link);
});

上面的代码将打开外部应用程序,然后会弹出“确定”警报,单击“确定”后,我再次调用相同的代码。如果需要,可以循环执行此操作。

提示:
现阶段我们引导用户使用分屏。例如,用户可以将您的网络应用程序停靠在左侧,将外部应用程序停靠在右侧。

警报框:
我们使用 Alerty.js https://github.com/undead25/alerty#readme

The only way to bypass this "bug" is to ask the user twice (or in a loop) by showing a OK alert or some sort of user confirm box.

My solution:

OpenLinkInExternalApp(Link);
alerty.alert('', { title: '', okLabel: 'Open Link'  }, function () {
    OpenLinkInExternalApp(Link);
});

The above code will open the external app, then a OK alert will pop up, after clicking OK, I call the same code again. Do this in a loop if needed.

TIP:
We guide our users to use split screen at this stage. This is where users can dock your web-app on the left and the external app on the right as an example.

Alert Box:
We user Alerty.js https://github.com/undead25/alerty#readme

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文