Last active
December 20, 2015 12:49
-
-
Save sjmach/6134245 to your computer and use it in GitHub Desktop.
How to display a dialog to a user when the internet is switched off in Phonegap.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wait for Cordova to load | |
document.addEventListener("deviceready", onDeviceReady, false); | |
// Cordova is ready | |
function onDeviceReady() { | |
document.addEventListener("offline", whenOffline, false); | |
return false; | |
} | |
function whenOffline() { | |
navigator.notification.alert( | |
'Sorry your internet connection is not working, please enable it !', // message | |
alertDismissed, // callback | |
'Settings', // title | |
'Done' // buttonName | |
); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment