Ionic Structure - Internet Connection Detection
I am developing a simple application using the Ionic framework (and AngularJs) that fetches json data from my web page. How can I detect if there is an "Internet connection" and display a message to the user: "Connect to the Internet" if not.
EDIT
Can I use the cordova API to do this?
source to share
Cordova provides a plugin org.apache.cordova.network-information
.
This plugin provides an implementation of the old version of the Network Information API. It provides information about the cellular and wireless connection of the device and whether the device has an Internet connection.
source to share
If I'm not mistaken, this plugin only detects if Wi-Fi or cellular is enabled on the device. This does not always mean that the application can actually reach your remote server if you are connected to a WiFi network without an Internet connection. So the only solution I have found to allow the application to access the remote server is to ping the server all the time.
source to share