Ionic 2 network.type = null

Asked

Viewed 115 times

0

I am developing an application in Ionic 2 ts, but when I try to check if it is connected on the internet it returns null. My code

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


@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers: [ProviderAccessApi]
})
export class HomePage {
  user : string;
  pass:string;

  constructor(public navCtrl: NavController, public providerAPI:ProviderAccessApi, private platform: Platform, public alertCtrl : AlertController, public network : Network) {
      console.log('HomePage carragada com sucesso')
      alert(network.type);
  }

How can I fix ?

  • You followed these steps?

  • Yes, but I only put the network.type, without connecting disconnects... But I put in the appmodule everything...

  • Now it worked, I tested it on iPhone, not emulator

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.