ionic 2 - inappbrowser "browser.on(...).subscribe is not a function" error

Viewed 8102

I follow this http://ionicframework.com/docs/native/in-app-browser/ document for use inappbrowser and try with below steps :

1- install

ionic cordova plugin add cordova-plugin-inappbrowser 

 npm install --save @ionic-native/in-app-browser

2 - Add this plugin to app.module.ts provider

3 - add to constructor :

constructor(private iab: InAppBrowser) { }

4- and use it in launch method like this :

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

launch(urlc){
      let url = 'https://example.com/';
      let browser = this.iab.create(url, '_blank', 'location=yes');
      browser.on('loadstart').subscribe((ev: InAppBrowserEvent) => {
          this.close_status=true;
      });
  }

but when serve and call launch method I see this error :

Runtime Error
browser.on(...).subscribe is not a function
2 Answers

If you want to avoid this error you have 3 options:

  1. Run the app in a real device.
  2. Run the app in an emulator.
  3. Run the app in a browser, using the "Browser" platform (which is supported by the InAppBrowser plugin). Instead of doing:

    ionic serve

do:

ionic cordova run browser
Related