Skip to content

Instantly share code, notes, and snippets.

@alunny
Created November 8, 2012 17:52
Show Gist options
  • Save alunny/4040367 to your computer and use it in GitHub Desktop.
Save alunny/4040367 to your computer and use it in GitHub Desktop.
// all pseudo-code
document.addEventListener('deviceready', function (e) {
if (device.platform == 'android') {
window.plugins.pushNotification.register({
senderID: '[email protected]',
onevent: onEvent,
onsuccess: onRegister,
onerror: onFail
});
} else {
window.plugins.pushNotification.register({
onevent: onEvent, // sugar for subscribing to push-notification evt
onsuccess: onRegister,
onerror: onFail
allowBadge: false,
allowSound: false,
allowAlert: true
});
};
}, false);
function onEvent(e) {
var msg;
if (e.type == 'message') {
msg = JSON.parser(e.message);
// do stuff with msg
}
}
function onRegister(e) {
// do whatever needs to be done
}
function onFail(e) {
console.log(e.message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment