Reputation: 1525
I'm using phonegap with jquery mobile and I want to check the internet connection regularly. From what I have read in other questions that are similar, I can't only use document.addEventListener("online", onOnline, false); because that is only fired when your app is already is loaded and regains a connection. This is not fired on start of the application. I also can't rely on navigator.network.connection.type; because that will apparently only tell me whether or not I'm connected to a router and not necessarily to the internet. Using an Ajax call to GET the google homepage as an alternate way to check connection doesn't work in phonegap for me because it returns a '404 not found error'
What are the other options? I'm not Terminal proficient so some of the documentation for exotic plugins are very hard for me to follow.
Upvotes: 0
Views: 104
Reputation:
@Spilot,
As with all things Cordova/Phonegap, use a plugin. Your understanding of the cordova-plugin-network-info "core" plugin is incorrect. source code – android demo app (This demo gone after March 20, 2016)
There is more than one way to check a network connection. Search for:
However, if you are looking connection to certain services, then those services should have some type of "connection status". Such as, firebase's offline -> example.
Upvotes: 1