在 Ion-Content USNG 应用内浏览器中打开网页



我想使用应用内浏览器在我的应用程序中呈现网页。 该页面应显示在离子内容部分中

有什么办法,我可以打开它。我将非常感谢一些帮助。

谢谢。

你应该分享到目前为止的代码。

我以为这将通过iFrame解决,但听起来ios商店可能不赞成这种方法。

在研究时,我发现这个:

Ionic 4 InAppBrowser第三方支付解决方案 | umeaworks

这谈到了他们是如何做到的。这似乎很标准:

openBrowser(url: string, target: string) {
const browser: InAppBrowserObject = this.theInAppBrowser.create(url, target, this.options);
const btn: HTMLElement = this.hiddenBtn.nativeElement as HTMLElement;
if (browser.on('loadstop')) {
browser.on('loadstop').subscribe((ev: InAppBrowserEvent) => {
// do whatever is needed here, for example check the url of the browser event
if (ev.url) {
// do stuff based on url and url parameters
// in our solution we got an order id from a confirmation page
}
// for the event to trigger we added a hidden button to interact with the screen
btn.click();
});
}
}

使用以下选项:

options: InAppBrowserOptions = {
location: 'yes',
hidden: 'no',
clearcache: 'yes',
clearsessioncache: 'yes',
zoom: 'yes',
hardwareback: 'yes',
mediaPlaybackRequiresUserAction: 'no',
shouldPauseOnSuspend: 'no',
closebuttoncaption: 'Close',
disallowoverscroll: 'no',
toolbar: 'yes',
enableViewportScale: 'no',
allowInlineMediaPlayback: 'no',
presentationstyle: 'pagesheet',
fullscreen: 'yes',
footer: 'yes'
};

文章还指出,需要一种解决方法 - 触发假按钮按下以将焦点放在屏幕上,否则它将无法正常运行:

<ion-button #hiddenBtn style="display:none">hidden</ion-button>

和:

@ViewChild('hiddenBtn') hiddenBtn: ElementRef;

如果这不能解决您的答案,请更新您的问题,详细说明您尝试过的内容以及具体出错的地方。

最新更新