InAppBrowser.on('loadstop') not working

I am cannot use .on in InAppBrowser i need help my code is:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { InAppBrowser } from "@ionic-native/in-app-browser";

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private iab: InAppBrowser) {

  }

  doLoginTwitter() {
    const browser = this.iab.create("http://xxxxxxx.com/api.php",  '_self');
    browser.on('loadstop').subscribe(function(event){
      console.log("LOG: API Response");
      console.log(event);
    });
  }

}

I’ve tried it anyway but it never works on loadstart and loadstop does not work I want to know why it does not work I’m testing on my cell phone using Ionic DevAPP but it still does not work, it opens the normal API window but it does not work fires the logs on the console I am using the ionic command --lab -c to start the ionic server and it does not work please help me.

2 Likes

Have you tested loadstop with other web pages, where you’re sure the loading stops?

Yes I tested with google.com.
luisjustin.com.br
ionicframework.com
and hiestas worked.

1 Like

So .on('loadstop') works fine on other pages, but not on your mystery page?

It is not working on the pages I mentioned above.

1 Like

From so much testing I came to the conclusion that the problem is when it is created using the method “_self” if using “_blank” everything works normal.

    import { Component } from '@angular/core';
    import { NavController } from 'ionic-angular';
    import { InAppBrowser, InAppBrowserEvent } from "@ionic-native/in-app-browser";
    
    @Component({
      selector: 'page-home',
      templateUrl: 'home.html'
    })
    export class HomePage {
    
      constructor(public navCtrl: NavController, private iab: InAppBrowser) {
    
      }
    
      doLoginTwitter() {
        const browser = this.iab.create("http://luisjustin.com.br/api.php",  '_blank', 'location=no');
        browser.on('loadstop').subscribe((event: InAppBrowserEvent) => {
          console.log("LOG: API Response");
          console.log(event.url);
        });
      }
    
    }
4 Likes