Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joshbuchea
Created February 5, 2015 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbuchea/9653a1ea63d0661c012c to your computer and use it in GitHub Desktop.
Save joshbuchea/9653a1ea63d0661c012c to your computer and use it in GitHub Desktop.
Cordova - window.alert → Native Notifications
document.addEventListener('deviceready', function () {
if (navigator.notification) { // Override default HTML alert with native dialog
window.alert = function (message) {
navigator.notification.alert(
message, // message
null, // callback
"Notification Title", // title
'OK' // buttonName
);
};
}
}, false);
@joshbuchea
Copy link
Author

This snippet requires adding the native dialogs plugin to your project:

cordova plugin add org.apache.cordova.dialogs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment