I like this better as well, verse having to put in a if then else block based on mobile OS, which is error prone.
Question about the JS syntax above - it looks odd to have the configuration object below the function(error), I assume I could have declared the config object above and used it as a parameter to push.register(). When JS gets too creatively away from old school (e.g. Java 1.5) syntax it tends to throw me off. :-)
How else could the block above be written to look more "straightforward"? keeping in mind that our average user is a Struts/SpringMVC kind of developer.
var pushConfig = {
pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
alias: "<alias e.g. a username or an email address optional>",
android: {
senderID: "<senderID e.g Google Project ID only for android>",
variantID: "<variantID e.g. 1234456-234320>",
variantSecret: "<variantSecret e.g. 1234456-234320>"
},
ios: {
variantID: "<variantID e.g. 1234456-234320>",
variantSecret: "<variantSecret e.g. 1234456-234320>"
}
};
push.register(onNotification, errorHandler, pushConfig);
function onNotification(event) {
alert(event.alert);
}
function errorHandler(error) {
throw error;
}