Question as posted on StackOverflow but without much success there …
I’m currently working on an Ionic Project that involves opening a web page from within the app. I resorted to the InAppBrowser Cordova plugin for this. Because there’s some JS going on, on the page to which you are redirected it somehow needs to be a _system browser. (It doesn’t seem to execute the JS code correctly in the _self or _blank browser).
I read there were some issues with the eventHandlers getting lost on the system browser but couldn’t find any recent solutions for closing the system browser and returning to the application on a specific event (loadstop for example).
The code in itself is pretty simple and self-explanatory. The problem is that it doesn’t seem to bind to the ‘loadstop’ event. The other issue is that the ‘close’ method also doesn’t seem to work for the system browser.
Does anyone have a recent solution for this? I added a snippet of the code bellow:
printLabel(): void {
// labelUrl is a property on article that contains the url to redirect to (this is present and works)
const browser = this.iab.create(this.article.labelUrl, '_system');
// the JS script makes sure the label is printed so once the page is loaded it should close and return to the application
browser.on('loadstop').subscribe(() => {
browser.close();
});
}