@garbarino/gb-jscommons
Advanced tools
Comparing version 1.1.7 to 1.2.0
@@ -63,3 +63,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function sendSubscriptionToBackEnd(subscription) { | ||
function sendSubscriptionToBackEnd(subscription, brand) { | ||
return fetch('/api/save-subscription/', { | ||
@@ -66,0 +66,0 @@ method: 'POST', |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["push-notifications"]=n():(e.gbJsCommons=e.gbJsCommons||{},e.gbJsCommons["push-notifications"]=n())}("undefined"!=typeof self?self:this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(){return"serviceWorker"in navigator&&"PushManager"in window}Object.defineProperty(n,"__esModule",{value:!0}),n.isCompatible=r,n.canAskForPermission=function(){return r()&&"denied"!==Notification.permission},n.subscribeUserToPush=function(){return r()?navigator.serviceWorker.getRegistration().then(function(e){var n={userVisibleOnly:!0,applicationServerKey:o};return e.pushManager.subscribe(n)}).then(function(e){return console.log("Received PushSubscription: ",JSON.stringify(e)),e}):Promise.reject("Push notifications not compatible")},n.getSubscription=function(){return r()?navigator.serviceWorker.getRegistration().then(function(e){return e.pushManager.getSubscription()}):Promise.reject("Push notifications not compatible")},n.sendSubscriptionToBackEnd=function(e){return fetch("/api/save-subscription/",{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"32223507-c36c-42c2-b52d-b3f1d65fa5ae"},body:JSON.stringify(e)}).then(function(e){if(!e.ok)throw new Error("Bad status code from server.");return e.json()}).then(function(e){if(!e.data||!e.data.success)throw new Error("Bad response from server.")})};var o=function(e){for(var n=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),t="undefined"!=typeof window?window.atob(n):"",r=new Uint8Array(t.length),o=0;o<t.length;++o)r[o]=t.charCodeAt(o);return r}("BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U")}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["push-notifications"]=n():(e.gbJsCommons=e.gbJsCommons||{},e.gbJsCommons["push-notifications"]=n())}("undefined"!=typeof self?self:this,function(){return function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=0)}([function(e,n,t){"use strict";function r(){return"serviceWorker"in navigator&&"PushManager"in window}Object.defineProperty(n,"__esModule",{value:!0}),n.isCompatible=r,n.canAskForPermission=function(){return r()&&"denied"!==Notification.permission},n.subscribeUserToPush=function(){return r()?navigator.serviceWorker.getRegistration().then(function(e){var n={userVisibleOnly:!0,applicationServerKey:o};return e.pushManager.subscribe(n)}).then(function(e){return console.log("Received PushSubscription: ",JSON.stringify(e)),e}):Promise.reject("Push notifications not compatible")},n.getSubscription=function(){return r()?navigator.serviceWorker.getRegistration().then(function(e){return e.pushManager.getSubscription()}):Promise.reject("Push notifications not compatible")},n.sendSubscriptionToBackEnd=function(e,n){return fetch("/api/save-subscription/",{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"32223507-c36c-42c2-b52d-b3f1d65fa5ae"},body:JSON.stringify(e)}).then(function(e){if(!e.ok)throw new Error("Bad status code from server.");return e.json()}).then(function(e){if(!e.data||!e.data.success)throw new Error("Bad response from server.")})};var o=function(e){for(var n=(e+"=".repeat((4-e.length%4)%4)).replace(/\-/g,"+").replace(/_/g,"/"),t="undefined"!=typeof window?window.atob(n):"",r=new Uint8Array(t.length),o=0;o<t.length;++o)r[o]=t.charCodeAt(o);return r}("BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U")}])}); |
@@ -42,3 +42,3 @@ const APPLICATIONSERVERKEY = urlB64ToUint8Array('BEl62iUYgUivxIkv69yViEuiBIa-Ib9-SkvMeAtA3LFgDzkrxZJjSgSnfckjBJuBkr3qBUYIHBQFLXYp5Nksh8U'); | ||
export function sendSubscriptionToBackEnd(subscription) { | ||
export function sendSubscriptionToBackEnd(subscription, brand) { | ||
return fetch('/api/save-subscription/', { | ||
@@ -45,0 +45,0 @@ method: 'POST', |
{ | ||
"name": "@garbarino/gb-jscommons", | ||
"version": "1.1.7", | ||
"version": "1.2.0", | ||
"description": "A package of common functions used in our JavaScript applications.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
20372