Created
November 8, 2012 17:52
-
-
Save alunny/4040367 to your computer and use it in GitHub Desktop.
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
// 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