service-worker

React w/ Service Worker & Push Notifications

邮差的信 提交于 2019-12-05 20:08:58
Some initial considerations: "react": "^16.8.2", "react-scripts": "2.1.5" I have created a new react app and I need to implement Push Notifications. Following this tutorial, I was able to get up and running in 5 minutes, but now I have to implement the same strategy (kinda) into a react app. The problem I am facing is that I am able to subscribe to the Notification API, but I'm not sure how to edit the service-worker.js file to add an event listener to catch the push event ( Handle a Push Event chapter in the google guide) Customizing your service worker with Create React App is possible, but

Handling authentification to Firebase Database with Fetch in a Service Worker

守給你的承諾、 提交于 2019-12-05 18:30:53
I'm trying to query a Firebase database from a Service Worker using the Fetch API. However it doesn't work as expected as I can't get authenticated correctly. Basically what I'm trying to do is from origin https://myproject.firebaseapp.com inside a Service Worker I do a call like this : var fetchOptions = {}; fetchOptions.credentials = 'include'; var url = options.messageUrl; var request = new Request('https://myproject.firebaseio.com/user/foobar.json', fetchOptions); messagePromise = fetch(request).then(function(response) { return response.json(); }); I'm getting this error : Fetch API cannot

Why do service workers only work over HTTPS?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 14:28:16
Per the original proposal, regarding "Prefer Secure Origins For Powerful New Features" “Particularly powerful” would mean things like: features that handle personally-identifiable information, features that handle high-value information like credentials or payment instruments, features that provide the origin with control over the UA's trustworthy/native UI, access to sensors on the user's device, or generally any feature that we would provide a user-settable permission or privilege to. Please discuss! “Particularly powerful” would not mean things like: new rendering and layout features, CSS

XMLHttpRequest within service worker

柔情痞子 提交于 2019-12-05 14:06:26
I'm trying to create a push notification system on chrome. I have a php that fetches data from mysql and echoes a JSON, now I'd like to call a function getJsonCode() that it's activated when a push notification arrives and reads the JSON data. Within my service worker I've created the standards functions. The problem is that when I create getJsonCode with a XMLHttpRequest it tells me it's not defined self.addEventListener('install', function(event) { self.skipWaiting(); console.log('Installed', event); }); self.addEventListener('activate', function(event) { console.log('Activated', event); });

Service worker not run in offline mode using nodejs server

半城伤御伤魂 提交于 2019-12-05 13:19:18
i've been create new project PWA. when i develop not using node js for (socket.io running) just running in offline like i expected and needed. but when integration with nodejs server. when go online the app running well not get any problem. but when i change to offline mode my service work not run but show offline browser. this my code node js server: var express = require('express'); var app = express(); var server = require('http').Server(app); var io = require('socket.io')(server); var cors = require('cors'); app.use(cors()); app.use(express.static(__dirname + '/')); app.use(function(req,

Service Worker and transparent cache updates

喜夏-厌秋 提交于 2019-12-05 12:46:51
I am trying to install a ServiceWorker for a simple, yet old, Django web app. I started working with the example read-through caching example from the Chrome team This works well but isn't ideal because I want to update the cache, if needed. There are two recommended ways to do this based on reading all the other service-worker answers here. Use some server-side logic to know when the stuff you show has updated and then update your service worker to change what is precached. This is what sw-precache does, for example. Just update the cache version in the service worker JS file (see comments in

Service worker in Safari

穿精又带淫゛_ 提交于 2019-12-05 11:59:56
I have a major problem with service workers, or what I think is a service worker related problem. The problem I have (only in Safari) both on Mac and iOS is that every second time I visit a route I got a 504 (Gateway Timeout) message in the console and no data is fetched from the server. Thanks in advance, Mattias Tibin Thomas Disabling etag from server side fixed my issue. I was having the same problem, and I was able to fix this by delaying the API call (in a component) to be executed 300 milliseconds after the page reload. So my code looks like the following: ngOnInit() { setTimeout(this.

Uncaught (in promise) TypeError: Request failed pwa error

南楼画角 提交于 2019-12-05 10:44:15
问题 I am trying to build a Progressive Web App (PWA). The service worker shows registered, PWA audit shows everything good, but the console shows this error: TypeError: Request failed pwa error I am unable to cache the files. I tried all possible answers on Stack Overflow and it's the same //self.addEventListener('fetch', function(event) {}); var dataCacheName = 'myappData-v3n'; var cacheName = 'myapp-3n'; var filesToCache = [ 'images/logo.png', 'js/jquery.min.js', 'js/popper.min.js', 'js

PWA with multiple pages

我只是一个虾纸丫 提交于 2019-12-05 10:22:25
I'm creating a PWA for my website. It was a multiple page website built using jquery. Now I have created an app shell which consists of a common header for the site. My site has good SEO ranking and ranks in top 3 links usually. Now when I want to go from page A to page B and I want the header to be preloaded and a loader gets displayed until the data for page B is received from the server. I am still using jquery as most of the modules are already built in that and I don't want to rebuild them. Now the only solutions I can think of to achieve this is either using an ajax call or using routes

Is it possible to use the new Push Notifications support in Chrome without GCM?

安稳与你 提交于 2019-12-05 09:49:44
Can I use a push service other than Google's GCM when using the new Push API with service workers? Today, Chrome is the only browser that supports the standard push API so right now the short answer is No. A longer answer involves doing different things for different browsers Safari offers desktop notifications via APNS and a proprietary API Firefox is shipping support for push notifications soon and presumably will use a different push server than GCM. So to summarize, it seems that different combinations of Browser/OS will require different push servers. In the future there is an IETF draft