[aerogear-dev] cordova push plugin simplification
Sebastien Blanc
scm.blanc at gmail.com
Wed Feb 26 05:00:40 EST 2014
Great Ideas Erik !
Comments inline
On Wed, Feb 26, 2014 at 10:40 AM, Erik Jan de Wit <edewit at redhat.com> wrote:
> Hi,
>
> As you may have experienced or seen the cordova push plugin is not always
> simple to get started with, there are still some things that are platform
> specific even though compared to the 'original' it has improved there is
> room for improvement. Here are some suggestions to make it even simpler:
>
> Right now the API looks like this:
>
> var pushConfig = {
> // senderID is only used in the Android/GCM case
> senderID: "<senderID e.g Google Project ID only for android>",
> pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
> variantID: "<variantID e.g. 1234456-234320>",
> variantSecret: "<variantSecret e.g. 1234456-234320>",
> alias: "<alias e.g. a username or an email address optional>"}
> //badge and sound are iOS specific, and ignored on Androidpush.register(successHandler, errorHandler, {"badge": "true", "sound": "true",
> "ecb": "onNotification", pushConfig: pushConfig});
>
> Suggestion number one, is to remove the successHandler and use that as the
> callback for notifications:
>
> push.register(onNotification, errorHandler, {"badge": "true", "sound": "true", pushConfig: pushConfig});
>
> Now the Javascript can verify that the callback is a function because it's
> no longer a string and the need for a separate successHandler is overrated
> as you will either get messages or your errorHandler gets invoked.
>
True but it would be nice if we can still pass optionally a function for
the registration successHandler, depending on the developer needs maybe I
still wants to do something with his backend once the registration is
suceesful. But I agree to have a default "hidden" function for that ... but
should be able to override it.
>
> For iOS we have these badge and sound flags we could we get rid of those
> as well? When you don't want a badge then just don't send it in the
> message!? Then the pushConfig can be inlined making it look like this:
>
Not really understand here what you mean, could you elaborate a bit ?
> push.register(onNotification, errorHandler, {
> // senderID is only used in the Android/GCM case
> senderID: "<senderID e.g Google Project ID only for android>",
> pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
> variantID: "<variantID e.g. 1234456-234320>",
> variantSecret: "<variantSecret e.g. 1234456-234320>",
> alias: "<alias e.g. a username or an email address optional>"
> });
>
> Till now all these changes can be made on the plugin, but we could take it
> even further. Two things that are still platform dependent the senderId and
> the variantID/secret. Now senderId is 'known' by UPS so why do we need to
> specify it here? We could make senderId part of the response when
> registering a device on UPS then the client doesn't need to specify it and
> all configuration is in one place.
>
That will be a convention to skip the senderId when the variant is an
Android "type", yeah why not, I like that.
>
> That leaves variantID/secret and that is the boldest proposal. How about
> we make it possible to register for an application instead for a specific
> variant? Then based on the meta information (deviceType, operatingSystem
> and osVersion) we choose the right variant.
>
I like the idea but that can be tricky since multiple variants can have the
same meta information (like "Android Free"/"Android Premium"), we should
think about a convention. But again I like the idea and it is worth
thinking about it.
>
> If we do all of the above there will be no platform specific code at all
> and the final script could look as simple as this:
>
> push.register(function(event) {
> alert(event.alert);
> },
> function(error) {
> throw error;
> }, {
> pushServerURL: "<pushServerURL e.g http(s)//host:port/context >",
> applicationID: "<applicationID e.g. 1234456-234320>",
> secret: "<secret e.g. 1234456-234320>",
> alias: "<alias e.g. a username or an email address optional>"
> });
>
>
> Push notifications in one statement for all devices :)
>
> WDYT
> Erik Jan
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20140226/16f82dd5/attachment-0001.html
More information about the aerogear-dev
mailing list