gpt4 book ai didi

android - Android 上的 Ionic InAppBrowser 无法导航到自定义 Url Scheme

转载 作者:行者123 更新时间:2023-11-29 18:46:03 26 4
gpt4 key购买 nike

我有一个设置,我在插件 InAppBrowser 中打开一个带有目标“_blank”的 url。插件 Deeplinks 也已安装和配置。

const browser: InAppBrowserObject = this.iab.create(url, '_blank', <InAppBrowserOptions>{
location: "no",
toolbar: "no",
footer: "no"
});

browser.on('loadstart').subscribe((event: InAppBrowserEvent) => {
console.log(event);

if (event.url.indexOf('wflwr://payment/success') > -1) {
browser.close();
}

if (event.url.indexOf('wflwr://payment/cancel') > -1) {
browser.close();
}

if (event.url.indexOf('wflwr://payment/error') > -1) {
browser.close();
}
});

我将其缩短以仅显示重要部分。打开的url是https://www.voan.ch/wfl/ (这只是真正实现之前的模拟)

预期的行为是,单击 url 上的每个链接时,应用程序内的浏览器实例应关闭。这在 iOS 上按预期工作,但在 Android 上不起作用。该事件只是没有被触发。如果我将其中一个网址更改为例如<a href="https://www.google.com">CANCEL</a> , 然后事件被触发。

最佳答案

在最新的 pr 中添加了对此的支持

要使用它你需要两件事:

例如允许 whatsapp 自定义方案和 twitter

  • 使用您要支持的自定义方案添加新的 config.xml 首选项:
    <preference name="AllowedSchemes" value="whatsapp,twitter" />`
  • 添加事件监听器定制方案:
    inAppBrowserRef.addEventListener('customscheme', function (event) {
    //do whatever you want here like:
    window.open(event.url, "_system");
    });

关于android - Android 上的 Ionic InAppBrowser 无法导航到自定义 Url Scheme,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51908666/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com