Ionic-native: InAppBrowser without angular - Cannot read property 'subscribe' of undefined

Created on 15 Dec 2019  路  7Comments  路  Source: ionic-team/ionic-native

Hi. I am trying to use inAppBrowser without Angular like this:

import { InAppBrowser } from '@ionic-native/in-app-browser';

export const openBrowser = function(url: string) {
  let instance = InAppBrowser.create(url, '_blank', {
    hideurlbar: 'yes',
    fullscreen: 'yes',
    hardwareback: 'no',
    hidenavigationbuttons: 'yes',
    location: 'no',
  });

  instance.on('loadstop').subscribe(function() {
    instance
      .executeScript({
        code: "function getToken(){return localStorage.getItem('authToken');}getToken();",
      })
      .then(function(params) {
        console.log('params:', params);
        // let token = params[0];
        instance.close();
      });
  });

But then, I face an error saying Uncaught TypeError: Cannot read property 'subscribe' of undefined

Any idea how to fix this issue? Thanks.

Most helpful comment

I am trying the same, but still getting error

All 7 comments

Do you have rxjs installed?

Bump, having the same issue.

Yes, I do have rxjs installed.

Might be related to #2899

I'm having the same issue. Did you find a solution?

@mateoc10 unfortunately no... please let me know when you do...

@donfour I made it work by adding "_blank" and location: "yes". But it doesn't work on chrome while developing. On iOS and Android it works fine.
const browser = InAppBrowser.create(loginUrl, '_blank', { location: "yes" }) browser.on("loadstart").subscribe(info => { console.log("INFO", info) })

I am trying the same, but still getting error

Was this page helpful?
0 / 5 - 0 ratings