Not able to attach event handler in Ionic 2 on InAppBrowser

I’m very new to Ionic 2 framework and I’m trying to write an app in which I need to open an external URL in an embedded browser (InAppBrowser). I create an InAppBrowser instance and launch the browser. The browser opens and it also opens the link, but I keep getting an error.

Cannot read property 'addEventListener' of undefined
Here’s the code that I’m using:

let browser = new InAppBrowser(
    "http://www.google.com",
    "_blank",
    "location=no,hidden=yes",
);
console.log(browser);
browser.on('loadstop').subscribe(
    (res) => {
        // Handle url checking and body parsing here
    },
    (error) => {
        // Handle error here
    }
);
browser.on('deviceready').subscribe(
    (res) => {
        browser.show();
        console.log(res);
    },
    (error) => {
        console.log(error);
    }
);

I don’t understand what I’m doing wrong. I want to check what the url is everytime the browser loads a webpage and if it is the desired web page then parse the body of the browser and then close it.

I’m trying to integrate a payment gateway. So basically I load the payment url in the browser, user makes the payment and the payment gateway redirects the user to my backend url. Now I want to parse what my backend returns and close the browser. Also, that console.log(browser) in there does logs an instance of InAppBrowser.

why are you trying to listen for a 'deviceready' event? Does one even exist on the InAppBrowser?

This error still persists after removing the deviceready event.