service-worker

Can Service Worker push notification without gcm in chrome ?

流过昼夜 提交于 2019-12-04 16:31:42
Google's service include GCM can not access in my country.Can Service Worker push notification without gcm in chrome? Or if some hack technique can implement this? Nick Searle Chrome now also uses Firebase Cloud Messaging as its Push Service, which may be available in your country. You could also use a third party Push Notification platform. These would still need to access GCM or FCM but they might have some ways to get access in restricted areas. Just do a search for "push notification third party" to get a list of them. Also see this answer and this one for more information. Be aware they

Service Workers not updating

自古美人都是妖i 提交于 2019-12-04 16:28:12
问题 I have a service worker installed in my website, everything works fine, except when I push an update to the cached files, in fact; they stay catched forever and I seem to be unable to invalidate the cache unless I unsubscribe the worker from the `chrome://serviceworker-internals/ const STATIC_CACHE_NAME = 'static-cache-v1'; const APP_CACHE_NAME = 'app-cache-#VERSION'; const CACHE_APP = [ '/', '/app/app.js' ] const CACHE_STATIC = [ 'https://fonts.googleapis.com/css?family=Roboto:400,300,500

Why does this code fail to execute 'fetch'?

社会主义新天地 提交于 2019-12-04 15:20:19
I'm working on push notifications using service workers. I'm using the XHR(Ajax) approach to get my notification, here is a code snippet of service-worker.js: var API_ENDPOINT = new Request('/getNotification', { redirect: 'follow'}); event.waitUntil( fetch(API_ENDPOINT, {credentials: 'include' }) .then(function(response) { console.log(response); if (response.status && response.status != 200) { // Throw an error so the promise is rejected and catch() is executed throw new Error('Invalid status code from API: ' + response.status); } // Examine the text in the response return response.json(); })

How to include custom JS in AMP Page through SW?

孤者浪人 提交于 2019-12-04 15:01:38
We have gone through from all possible blogs of AMP but couldn't find any way to include custom JS in AMP. This blog( https://www.ampproject.org/docs/guides/pwa-amp/amp-as-pwa#extend-your-amp-pages-via-service-worker ) indicates that we can add Custom JS in AMP with the help of Service worker but haven't describe how to do it. Please let us know How to do it. Edit:- After adding JS at the run time, it again show the same old error, Please have a look to the image Note in the mentioned blog post that you can extend your AMP pages as soon as they’re served from the origin Having a service worker

How to cache APIs like Google Maps while using Service Workers

瘦欲@ 提交于 2019-12-04 13:16:39
Trying to cache Google Maps API response in Service Workers. Source Code: https://github.com/boopathi/sw-demo-iss/blob/gh-pages/sw.js Now I'm using all of the URLs that the Maps API would request to, but seems like a bad way, and I'm not able to cache everything, can I cache requests of some type and respond to requests of the same type. say, GET maps.googleapi.com/js?param1=value1 #and GET maps.googleapi.com/js?param2=value2&param3=value3 Is it possible to cache this as 'maps.googleapi.com/js' and while fetching inject last used params ? Jeff Posnick You can include logic in your fetch

Progressive Web App: offline cache does not work on Android, it works on Chrome dev Tools

筅森魡賤 提交于 2019-12-04 13:09:07
I have a simple PWA that works fine online. I have also tested the offline behaviour in Chrome Dev Tools, and the service worker is doing its job perfectly. But when I run the app from my Android phone, it doesn't work offline as the Cache Storage is no more present when offline. This is the service worker: var dataCacheName = 'myappData-v3n'; var cacheName = 'myapp-3n'; var filesToCache = [ '/meteosurf/', '/meteosurf/index.html', 'scripts/hammer.min.js', 'images/play_white.svg', 'images/stop_white.svg', 'images/back_white.svg', 'images/forward_white.svg', 'images/sfondo.jpg', 'images/ic

What's the right way to implement offline fallback with workbox

寵の児 提交于 2019-12-04 12:32:04
问题 I am implementing PWA into my project, I have setted up the serviceworker.js, and I am using workbox.js for cache routing and strategies. 1- I add the offline page to cache on install event, when a user first visit the site: /** * Add on install */ self.addEventListener('install', (event) => { const urls = ['/offline/']; const cacheName = workbox.core.cacheNames.runtime; event.waitUntil(caches.open(cacheName).then((cache) => cache.addAll(urls))) }); 2- Catch & cache pages with a specific

Chrome service-worker process running on port 3000?

谁说我不能喝 提交于 2019-12-04 12:27:18
问题 The following error shows up in my Rails app logs and in my Chrome JavaScript console, but only on Chrome, and only when the app is running on localhost on port 3000: Started GET "/service-worker.js" for 127.0.0.1 at 2015-12-15 09:31:04 -0800 ActionController::RoutingError (No route matches [GET] "/service-worker.js"): Apparently someone else has had this same problem, but solved it by reinstalling the OS (!). This isn't an option for me. According to lsof , there is some other some other

Angular Service Worker on the browsers that do not support it

ⅰ亾dé卋堺 提交于 2019-12-04 10:56:29
Angular team made a great job and introduced service workers support in the version 5. The documentation is quite helpful and I can really see how the things will work right after reading the related articles, however there is one topic that is not covered there. How does this all work in the browsers that do not support service workers. This is what's being said: Your application must run in a web browser that supports service workers. Currently, the latest versions of Chrome and Firefox are supported. To learn about other browsers that are service worker ready, see the Can I Use page. Can I

Progressive web app Uncaught (in promise) TypeError: Failed to fetch

别等时光非礼了梦想. 提交于 2019-12-04 09:18:08
问题 I started learning PWA (Progressive Web App) and I have problem, console "throws" error Uncaught (in promise) TypeError: Failed to fetch. Anyone know what could be the cause? let CACHE = 'cache'; self.addEventListener('install', function(evt) { console.log('The service worker is being installed.'); evt.waitUntil(precache()); }); self.addEventListener('fetch', function(evt) { console.log('The service worker is serving the asset.'); evt.respondWith(fromCache(evt.request)); }); function precache