How to check network coneection

everithing works fine, but it is normal take 3 seconds to fire online/offline events ?

You have two ways to check internet

  1. by connection object - install org.apache.cordova.network-information
  2. ngCordova plugin - install ngCordova for your project.

check this url can be useful.

http://goo.gl/eq2SHi

Yeah I see the same behavior; it takes 5+ seconds to recognize that the connection state has changed.

I run both example , its working fine. Yes its take some time.

Hereā€™s a good article which explains this in depth:

See my example: https://gist.github.com/jdnichollsc/7367fe5b17369e856157

basically is => $cordovaNetwork.isOnline()

Regards, Nicholls :grin:

As others have mentioned, use the cordova network plugin. I actually wrote a step by step tutorial on how to create an application that uses this plugin, and you can take a look at it here: http://www.nikola-breznjak.com/blog/codeproject/check-network-information-change-with-ionic-famework/.

Please let me know if it will prove to be helpful to you.

everything is good, just take care that you have to disconnect the wifi in emulator also. and wait for 2 3 seconds it works then.

Yeah, I also use the same plugin and everything was fine. But did anyone knows how to detect the internet connection loss when that connection is weak or maybe doesnā€™t have any data plan, even though already turn on the wifi/mobile data?

You have to check wether the backend functions you need are available by polling the backend.

Thanks @Robin. I already had ngCordova installed so this fit in nicely.
Cheers !!!

Here is a short and easy technique to check network connection . So just visit hereā€¦

Here are some articles that may help youā€¦
http://www.plugreg.com/plugin/apache/cordova-plugin-network-information

iam getting ReferenceError: Connection is not defined

iam getting ā€œReferenceError: Connection is not defined
at checkConnectionā€ what should i do now

Have you installed ngcordova ?

If I have wifi connection but no internet connecivity, How can I check that?