How to listen to inAppBrowser closed event
There are few things that is wrong in your code.
From the documentation browser.hide()
doesn't do what you want to do.
Hides an InAppBrowser window that is currently shown. Calling this has no effect if the InAppBrowser was already hidden.
_blank
replace it with _system
because _blank
opens in the inAppBrowser. You won't be able to listen for close event.
Now, you can subscribe to the browser and listen for it's events e.g.
//Events: loadstart, loadstop, loaderror, exit
browser.on('exit').subscribe(() => {
console.log('browser closed');
}, err => {
console.error(err);
});
I know it to late this issue was 3 years ago but the issue is an issue so here is the solution
1st import InAppBrowser
import {InAppBrowser} from '@ionic-native/in-app-browser/ngx';
2nd add to constructor()
constructor(private iab: InAppBrowser ) {}
3rd Now you can use on('xxx') where xxx is the event you want Events list: 'loadstart' | 'loadstop' | 'loaderror' | 'exit' | 'beforeload' | 'message' | 'customscheme'
In your case, you want to listen when inAppBrowser is closed check follwoing example:
anyFunName(url){
let openBrowser = this.iab.create(url, '_blank');
openBrowser.on('exit').subscribe(event => {
console.log("inAppBrowser is closed now");
// your action here when close inAppBrowser
});
}