GetNetworkStatus returns true if WiFi is on even if internet is not available.

GetNetworkStatus returns true if WiFi is on even if internet is not available.

  

Hi,

How does GetNetworkStatus() function detects status? I have a use case where I need app to work as offline but with wi-fi turned on and connected to local network (without internet access). But GetNetworkStatus returns true if wifi is connected even without internet. Is it how this function suppose to work? 

Is there a way to force offline mode or detect internet connection?


Thank you 


Solution

Hi Mykola,

The GetNetworkStatus() returns true if the device is connected to any network (Wi-fi, 3G, 4G, etc).
It does not check if there is actually internet connectivity.

One solution for you to check for internet connectivity is to use offline.js, or a similar library.

If you need more information from the device network, we are using the cordova network information plugin.


Thanks!

Solution

Thank you Ricardo.

I will try it

Ricardo Ferreira wrote:

Hi Mykola,

The GetNetworkStatus() returns true if the device is connected to any network (Wi-fi, 3G, 4G, etc).
It does not check if there is actually internet connectivity.

One solution for you to check for internet connectivity is to use offline.js, or a similar library.

If you need more information from the device network, we are using the cordova network information plugin.


Thanks!

Hello Ricardo,

When checking networkstatus using GetNetworkStatus() and the network is offline, there is an exception thrown containing the message "Request failed with an error". This message should be something like"Network error" or another message.

Also detecting Networkstatus changed react differently on android 4.4.2.

DO you have any example of a correct way of implemeting thiis?


Hi Lennard,

We weren't unable to reproduce that error. Can you show us how you are calling GetNetworkStatus? Can you attach your module to this thread so we can check it.

The usage is fairly simple, you just need to call it returns true if the device is connected to any network (Wi-fi, 3G, 4G, etc).

Also, regarding the differences in Android 4.4.2, what differences are you experiencing?

Thanks!