[aerogear-dev] cordova push plugin simplification

Erik Jan de Wit edewit at redhat.com
Fri Feb 28 08:59:36 EST 2014


> 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.


Of course we still can make it look like that, this is the same example but then without everything inlined still our average user will have to get used that we are referencing function ‘pointers’ here
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;
}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20140228/5d822320/attachment-0001.html 


More information about the aerogear-dev mailing list