Shivam Sarodia
Shivam Sarodia

Reputation: 417

Phonegap Internet Connectivity State

My app needs to know whether the device has internet connectivity or not - if it does, the application will show data from a server, and if it doesn't, the app will display previously cached data.

How reliable is the connection.type variable in PhoneGap 3.1 (compiled with PhoneGap Build)? Also, if the connection.type is UNKNOWN, does that indicate that the device does or doesn't have internet?

Upvotes: 0

Views: 65

Answers (1)

Andrew Lively
Andrew Lively

Reputation: 2153

The connection variable is very reliable, just as any of the other Cordova API's, just make sure you aren't trying to call it until after the deviceready event has fired.

When the connection.type is UNKNOWN, that is most likely because the Connection Manager wasn't initialized yet; take a look at this to help with this issue.

Upvotes: 1

Related Questions