Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49299

Is network still working?

$
0
0

Hi I tried use Network plugin but it doesn´t work. I writed code in constructor, function and service, but i can´t get it to work. My ask is if any of you it happens to them like me. The code I writed it´s content in documentacion. Thanks for reading me.

import { Network } from '@ionic-native/network/ngx';

constructor(private network: Network) {
let disconnectSubscription = this.network.onDisconnect().subscribe(() => {
  console.log('network was disconnected :-(');
});

let connectSubscription = this.network.onConnect().subscribe(() => {
  console.log('network connected!');
  // We just got a connection but we need to wait briefly
   // before we determine the connection type. Might need to wait.
  // prior to doing any api requests as well.
  setTimeout(() => {
    if (this.network.type === 'wifi') {
      console.log('we got a wifi connection, woohoo!');
    }
  }, 3000);
});
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49299


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