InAppBrowser Can't Subscribe to Event


#1

I’m trying to use Ionic Native’s Inappbrowser. Code taken

 platform.ready().then(() => {
        
        let url = 'https://google.com/'
        let browser = new InAppBrowser(url, '_self');

        browser.on('loadstop').subscribe((event) =>{
            console.log("loadstop");
            console.log(event.url); 
        })

    });

Firstly, I figured out with a lot of trouble that the github doc for cordova’s inappbrowser doesn’t apply to Ionic’s implementation of it; the Cordova plugin should allow:

browser.addEventListener('', function(){})

But instead within Ionic 2 it seems we need to do:

browser.on('event').subscribe(function(e){...})

Yet, my event never fires. I’m browsing all around the place, and my browser never logs the URL to my console.

What’s going on here / what am I doing wrong?


#2

This work for me:

    let option = "location=no,hidden=yes";
    let url = "http://www.muoversi.regione.lombardia.it/planner/jsp/mobile/index.html"
    let browser = new InAppBrowser(url, '_blank', option);
    browser.on('loadstop').subscribe(function(event) {
      console.log("subscribed");
      browser.show();
    });

Docs need a review…


#3

Could you tell me how to retrieve the last url visited ?

I tried this :

browser.on(‘exit’).subscribe(function(event) {
console.log(“URL”+event.url);
});

And

browser.on(‘exit’).subscribe((event) =>{
console.log(“URL”+event.url);
});

But url it’s always null…

TKs


#4

@NicoVTech Sorry I read only today your post. I can’t help because I only try the browser, I didn’t use it until now.


#5

hi, it seems the events are subscribed only if the target is not _self. Is there a way to catch iab events when the target is _self?
thanks