How to listen to inAppBrowser closed event


The following is the code that I am currently working with. I would like to understand how do I listen to the inAppBrowser close event? When some closes the inAppBrowser, the app should show some kind of alert message.

According to the documentation I have to use browser.close(), but this doesn’t work.

import { Component } from '@angular/core';
import { NavController, NavParams, Platform, LoadingController } from 'ionic-angular';
import { InAppBrowser } from 'ionic-native';

  selector: 'page-payment-information',
  templateUrl: 'payment-information.html'
export class PaymentInformationPage {

  constructor( public navCtrl: NavController, public navParams: NavParams, public platform: Platform, public loadingCtrl: LoadingController ) {
    this.platform = platform;

      let browser = new InAppBrowser('', '_blank', 'hidden=no,location=no,clearsessioncache=yes,clearcache=yes&enableViewportScale=yes');



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 => {

Answered By – Navneil Naicker

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published