diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-09-26 00:18:58 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-09-26 00:18:58 +0200 |
| commit | 3be2b3aea204f145d6e7c98d835891947105ed0e (patch) | |
| tree | 384742997ff7395ca9d43d71ae69c0744eddfe23 /StoneIsland/www/js/lib/etc/push.js | |
| parent | b6c70d0fdaa4c4d58e8e9e8e41a52bf32d36ef5b (diff) | |
push notification behaviors
Diffstat (limited to 'StoneIsland/www/js/lib/etc/push.js')
| -rwxr-xr-x | StoneIsland/www/js/lib/etc/push.js | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/StoneIsland/www/js/lib/etc/push.js b/StoneIsland/www/js/lib/etc/push.js index 1606199f..00a2e839 100755 --- a/StoneIsland/www/js/lib/etc/push.js +++ b/StoneIsland/www/js/lib/etc/push.js @@ -105,29 +105,40 @@ var push = (function(){ return sdk.cms() + '/_services/push/' + key } push.got_push_notification = function(push_obj) { - console.log('We received this push notification: ' + JSON.stringify(push_obj)); + // console.log('We received this push notification: ' + JSON.stringify(push_obj)); + app.blog.refresh() + + push_obj.additionalData = push_obj.additionalData || {} + + var is_hub = true try { - var is_hub = JSON.stringify(push_obj || {}).match(/hub/i) - if (is_hub) { - app.intro.$alert.show().html("[ HUB UPDATED ]") - } - else { - auth.clear_cart() - app.intro.$alert.show().html("[ STORE UPDATED ]") - } + is_hub = JSON.stringify(push_obj || {}).match(/hub/i) } catch (e) { + } + + if (is_hub) { app.intro.$alert.show().html("[ HUB UPDATED ]") } + else if (! push_obj.additionalData.url) { + auth.clear_cart() + app.intro.$alert.show().html("[ STORE UPDATED ]") + } if (push_obj.additionalData.foreground === false) { // TODO: route the user to the uri in push_obj pushPlugin.finish(function(){}, function(){}) } + else if (push_obj.additionalData.url) { + app.router.go(push_obj.additionalData.url) + } + else if (is_hub) { + app.router.go("hub") + } else { - app.route("intro") + app.router.go("intro") } } push.error = function(e){ |
