Ionic Network Plugin Not Working

Network Plugin not working in ionic
i am using cordova-plugin-network-information 2.0.1 “Network Information” in ionic
when i call to check network

  constructor(private platform: Platform,public navCtrl: NavController,private network: Network,public toastCtrl: ToastController)
  {
    this.platform.ready().then(() =>
    {

          this.network.onConnect().subscribe(() =>
          {
            console.log("calling 2");
            alert("Online!");
          });


          this.network.onDisconnect().subscribe(() =>
          {
            console.log("calling 4");
            alert("Offline!");
          });
    });
  }

and i m getting this error

ERROR Error: Uncaught (in promise): TypeError: Object(…) is not a function
TypeError: Object(…) is not a function
at Network.onConnect (index.js:62)
at home.ts:19
at t.invoke (polyfills.js:3)
at Object.onInvoke (core.js:4760)
at t.invoke (polyfills.js:3)
at r.run (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4751)
at t.invokeTask (polyfills.js:3)
at c (polyfills.js:3)
at polyfills.js:3
at t.invokeTask (polyfills.js:3)
at Object.onInvokeTask (core.js:4751)
at t.invokeTask (polyfills.js:3)
at r.runTask (polyfills.js:3)
at o (polyfills.js:3)
at e.invokeTask [as invoke] (polyfills.js:3)
at p (polyfills.js:2)
at HTMLDocument.v (polyfills.js:2)

1 Like