Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71530

Cannot access current network state. Type is always 'null'

$
0
0

@perzach wrote:

I'm using the ionic-native/network at startup in my app, and I want to check the initial network status by running network.type. The problem is that network.type always returns null or it is simply empty.

The network plugin works perfectly fine when using network.onConnect() and network.onDisconnect(), where I can handle a change in the internet connection, but I can't access the current network state after app launch.

Here is my home page:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Network } from '@ionic-native/network';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private network : Network) {
    console.log("Network type: " + network.type)
  }
}

And the console log:

Network type: null

Any ideas how to access the current network state without waiting for a certain change to happen?

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71530

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>