问题描述
我有一个设置,我在插件 InAppBrowser 中打开一个带有目标_blank"的 url.插件 Deeplinks 也已安装和配置.
I am having a setup, where I open a url in the plugin InAppBrowser with target '_blank'. The plugin Deeplinks is also installed and configured.
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();
}
});
我将其缩短以仅显示重要部分.打开的网址是https://www.voan.ch/wfl/(它是在真正实现之前只是一个 Mock)
I shortened it to show just the important parts. The url which is opened is https://www.voan.ch/wfl/ (it is just a Mock before the real implementation)
预期的行为是,单击 url 上的每个链接时,应用程序内的浏览器实例应该关闭.这在 iOS 上按预期工作,但在 Android 上却不行.事件只是没有被触发.如果我将其中一个网址更改为例如<a href="https://www.google.com">CANCEL</a>
,然后触发事件.
The expected behaviour is, that on a click on each of the links on the url, the browser instance inside the app should close. This works as intended on iOS, but not on Android. The event is just not triggered. If I change one of the urls to e.g. <a href="https://www.google.com">CANCEL</a>
, then the Event gets triggered.
推荐答案
在最新的 pr
要使用它,您需要两件事:
to use it you will need 2 things:
例如允许 whatsapp 自定义方案和 twitter
for example to allow whatsapp custom scheme and twitter
- 使用您想要支持的自定义方案添加新的 config.xml 首选项:<代码><preference name="AllowedSchemes" value="whatsapp,twitter"/>`
- 添加事件监听器customscheme:<代码>inAppBrowserRef.addEventListener('customscheme', function (event) {//在这里做任何你想做的事情:window.open(event.url, "_system");});
这篇关于Android 上的 Ionic InAppBrowser 无法导航到自定义 URL 方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!