Skip to content

Instantly share code, notes, and snippets.

@RhinoLance
Last active August 29, 2015 13:56
Show Gist options
  • Save RhinoLance/9059555 to your computer and use it in GitHub Desktop.
Save RhinoLance/9059555 to your computer and use it in GitHub Desktop.
Cordova notification wrappers
if (typeof navigator.notification === 'undefined') {
navigator.notification = {
confirm: function (message, confirmCallback, title, buttonLabels) {
setTimeout(function (){
if (window.confirm(message)) {
confirmCallback(1);
}
else {
confirmCallback(2);
}
}, 0);
},
prompt: function (message, callback, title, buttonLabels) {
setTimeout(function(){
var result = window.prompt(message, title);
callback({
buttonIndex: 1,
input1: result
});
}, 0);
},
alert: function (message, callback, title, buttonName) {
setTimeout(function() {
alert(message);
callback();
}, 0);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment