Property 'type' does not exist on type 'typeof Network'?

Hi! I was trying to make my connectivity provider then I got the error above. Could someone help? Thanks in advance. here is the code:

import { Injectable } from '@angular/core';
import { Network } from 'ionic-native';
import { Platform } from 'ionic-angular';
import { Observable } from 'rxjs/Observable';

declare var Connection;

@Injectable()
export class Connectivity {
  

  onDevice: boolean;

  constructor(public platform: Platform){
    this.onDevice = this.platform.is('cordova');
  }

  isOnline(): boolean {
    if(this.onDevice && Network.type){
      return Network.type != 'none';
    } else {
      return navigator.onLine; 
    }
  }

  isOffline(): boolean {
    if(this.onDevice && Network.type){
      return Network.type == 'none';
    } else {
      return !navigator.onLine;   
    }
  }

  watchOnline(): Observable<any> {
    return Network.onConnect();
  }

  watchOffline(): Observable<any> {
    return Network.onDisconnect();
  }

}
1 Like

Try using:

import { Network } from 'ionic-native'; export class Connectivity { isOffline() { return navigator.onLine; } }

It returns boolean true if online.

1 Like

I am getting below error