Network.type resolves to "null" even though connection is present


#1

hi there,
i want to check if a network connection is present, when the app gets started.
i tried.

setTimeout(() => {
	         console.log(Network.type);
	     }, 3000);

and i just get “null” even though a network connection is present.
the network.onDisconnect() and network.onConnect() handlers work correctly.
Is this maybe connected to degugging in browser?

Thanks


#2

Because this is a native plugin you have to test it on a real device.


#3

aha, thanks.
how can i handle this information in browser web-app though?


#4

You could use it through navigator.onLine which is described over here:

Or if you’re using sockets, you could detect of your connected or not.

What’s the specific use case?


#5

thanks. yes, navigator.onLine does look good.
usecase is: informing the user that he can not login / register / interact when offline