Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 654
Reza Mazarlou Avatar asked Jun 02 '17 12:06

Reza Mazarlou


1 Answers

InAppBrowser is a cordova plugin, and because of that, it's not available when running the app in the browser with ionic serve.

Try to run the app on a simulator / real device to use the plugin.

like image 171
sebaferreras Avatar answered Nov 10 '22 23:11

sebaferreras