hamzanatek
hamzanatek

Reputation: 404

Show a page to tell users to check their connection on PhoneGap

im Working with PhoneGap, im building an application with connection mode, and i want to show for users to check their internet when they are offline to use the my app, how can i do this ?

Upvotes: 3

Views: 35

Answers (1)

Kerri Shotts
Kerri Shotts

Reputation: 2372

Two ways:

  • navigator.onLine, see MDN Documentation for details.

  • The Network Information plugin lets you check if there is a connection available, and if so, what type of connection is in use (but you should not rely on the connection type — there are lots of ways the connection type can mislead you.)

However, you should not rely on these to determine if your app has a connection to your backend. Short of having no connection whatsoever, you should always attempt to route to your host, since having a connection doesn't guarantee that your host is reachable. The host could be down, or the user could be behind a network that doesn't let them out.

As to the user interface, that's entirely up to you. Avoid lots of technical verbage, and keep the message simple but clear.

Upvotes: 1

Related Questions