service-worker

Background Sync codes not working automatically when online(wifi on) in PWA

蓝咒 提交于 2019-12-13 03:58:00
问题 I am new to PWA and have been testing my PWA project using firebase console database. When offline, I have code to save my post data in indexedDB when i submit my post data to saved later when there is WiFi(online). It did save the data in indexedDB when no WiFi found, but when i turn on my WiFi, it doesn't post my data in realtime. When i submit new post data when wifi on(online), background sync codes do post saved data from indexedDB with newly post data in real time. But i want my

Service Worker - Push notification with VAPID prv/pub keys

↘锁芯ラ 提交于 2019-12-13 03:44:59
问题 A couple of years ago I implemented push notification with service worker on a project I was working on, by registering an app on Firebase, and using the registration number as part of the manifest.json file on the server side app. In that case I requested the user to allow notifications, got the browser registration once, saved on server side, and all works fine. I'm now trying to implement a similar solution, but using the VAPID (https://developers.google.com/web/ilt/pwa/introduction-to

Unable to store web notifications received in service worker in indexDB

余生颓废 提交于 2019-12-13 03:43:17
问题 I am using Firebase cloud messaging. I am using the below sample link. https://github.com/firebase/quickstart-js Notifications are received. I want to store notifications in indexDB in service worker. var setupDone = false; var storage = { setup: function() { return new Promise(function(resolve, reject) { var request = indexedDB.open(notificationdb, 1); request.onsuccess = function (e) { setupDone = true; var db = e.target.result; storage.db = db; resolve(); }; request.onupgradeneeded =

Custom Push Service

冷暖自知 提交于 2019-12-13 02:52:34
问题 In the context of pushing notifications to web-browsers, the PUSH SERVICE acts as interface between the SERVICE WORKER and APPLICATION SERVER. My current understanding is that Google FCM is the Push Service for Google Chrome & FireFox browsers APNS (Apple Push Notification Service) is the Push Service for Safari browser Here, is it technically possible to substitute the ‘push service(s)’ (– i.e., Google FCM for Google Chrome & FireFox browsers and APNS for Safari) with a generic custom

Firebase Cloud Messaging (WebPush) token expiration handling

∥☆過路亽.° 提交于 2019-12-13 01:09:51
问题 As I found out in Firebase source, every token has an expiration time of one week. And because messaging().onTokenRefresh is not implemented now, I'm assuming that there is no way of sending webpush-notifications to users that haven't been on my website with configured FCM for a week or longer. Or my assumption is incorrect and this expiration exists only on browser side? And tokens on the server-side of FCM aren't expiring without a call from browser to recreate token? 回答1: It's not an

Play a sound from a Service Worker

≯℡__Kan透↙ 提交于 2019-12-13 00:38:37
问题 Is there a way to play an audio file from a service worker? I'm trying to use io.sound library but it is a JavaScript plugin that requires window , so it doesn't work. EDIT As suggested by Jeff I'm trying to open a new window and post a message to that window. this is my code: function notifyClientToPlaySound() { idbKeyval.get('pageToOpenOnNotification') .then(url => { console.log("notifyClientToPlaySound", url); clients.matchAll({ type: "window" //includeUncontrolled: true }) .then(

node.js - how Caching handlebars.js using service worker

旧时模样 提交于 2019-12-12 19:21:48
问题 I want to ask about service workers. I made a web application and try to implement services worker. I'm using .hbs for my views layout and when I cache static files I can't cache the .hbs, .css and .js files. this is how i save my file: public/ css/ style.css js/ app.js manifest.json service-worker.js views/ home.hbs partial/ header.hbs When I deploy my app it fails to cache the home.hbs, style.css and my app.js file; I cant access my web offline. What should I do to fix it? This is my app.js

Can service-worker stop push notification sent by GCM api?

删除回忆录丶 提交于 2019-12-12 18:07:09
问题 In my current architecture, I submit push notifications using the GCM API. This triggers a 'push' event in the service worker. The service worker then adds some data to the notification. If the service worker is unable to add the data, due to some error, I am getting a blank notification. Can service workers avoid showing notifications sent by GCM? 回答1: From the Push Notifications guide at Google Developers: You must pass a {userVisibleOnly: true} argument to the subscribe() method. This

Custom HTTP Header for a specific file

折月煮酒 提交于 2019-12-12 17:34:27
问题 I am trying to set a header for a specific file via my htaccess file in order to give my service worker access to my root. Unfortunately I don't see the header appearing... Perhaps I am not targeting the file (https://www.stefanklokgieters.nl/wp-content/themes/stefanklokgieters/serviceworker.js) correctly? # Add custom header to single file <Files "/wp-content/themes/stefanklokgieters/serviceworker.js"> Header set Service-Worker-Allowed "/" </Files> # BEGIN WordPress <IfModule mod_rewrite.c>

Service worker to save form data when browser is offline

流过昼夜 提交于 2019-12-12 14:23:20
问题 I am new to Service Workers, and have had a look through the various bits of documentation (Google, Mozilla, serviceworke.rs, Github, StackOverflow questions). The most helpful is the ServiceWorkers cookbook. Most of the documentation seems to point to caching entire pages so that the app works completely offline, or redirecting the user to an offline page until the browser can redirect to the internet. What I want to do, however, is store my form data locally so my web app can upload it to