Open bohdaq opened 7 years ago
Where is urlBase64ToUint8Array
mentioned in the tutorial?
By the way the function is defined at https://github.com/GoogleChrome/push-notifications/blob/master/app/scripts/main.js
(Considering this issue is still relevent)urlBase64ToUint8Array is mentioned on this page: https://developers.google.com/web/fundamentals/push-notifications/subscribing-a-user
If needed here's the function
/**
* urlBase64ToUint8Array
*
* @param {string} base64String a public vavid key
*/
function urlBase64ToUint8Array(base64String) {
var padding = '='.repeat((4 - base64String.length % 4) % 4);
var base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
var rawData = window.atob(base64);
var outputArray = new Uint8Array(rawData.length);
for (var i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
}
return outputArray;
}
I've also found this: https://www.npmjs.com/package/urlb64touint8array
The real question. Why is this not built into browsers?
Tutorial does not have urlB64ToUint8Array function declared.
When user will try to make Push Notifications work, they will end up with non existing urlB64ToUint8Array method.
Please include sample into tutorial