Search code examples
apiionic4progressive-web-appsinstagram-apiinappbrowser

How to get URL with loadstart event in app browser in ionic 4 for instagram api?


I try to get URL with inAppBrowser in ionic 4 for my instagram api. I build PWA and smartphone applications. . Why loadstart event does not work when I build in PWA ?

I've already tried to get with in app browser plugin for ionic4 and with javascript (window.open() method).

In app Browser work when I build my IOS app. That doesn't work when I build my PWA app/

//instagram API
let authUrl = `https://www.instagram.com/oauth/authorize/?client_id=${client_id}&redirect_uri=${redirect_uri}&response_type=token&scope=public_content`;

//create in app browser
    var browser = this.iab.create(authUrl, '_blank');
//test loadstart event
    browser.on('loadstart').subscribe(event => {
      alert('loadstart');
      alert(event.url);
    }, err => {
      alert("InAppBrowser loadstart Event Error: " + err);
    });   

//test loadstop event
    browser.on('loadstop').subscribe(event => {
      alert('loadstop');
      alert(event.url);
    }, err => {
      alert("InAppBrowser loadstop Event Error: " + err);
    });
  }

PWA output : loadstop event.url == ""

IOS output : loadstart event.url == url loadstop event.url == ""

Thank you :)


Solution

  • inAppBrowser is a cordova plugin it will work fine in android & ios App, but pwa is completely web app it will not support cordova plugin, So it's better to show it in a component it will work fine.