progressive-web-apps

I need to access localstorage or cookie from within the serviceworker

跟風遠走 提交于 2019-12-05 00:02:47
I wish to make a fetch call after the push event for fetching the notif data through an internal api with user specific params which are stored in the localstorage or cookie such as usertype or country id .. how do i do this ? You cannot use Local Storage in service workers. It was decided that service workers should not have access to any synchronous APIs. You can use IndexedDB instead, or communicate with the controlled page using postMessage() . By default, cookies are not included with fetch requests, but you can include them as follows: fetch(url, {credentials: 'include'}) . 来源: https:/

Uncaught (in promise) TypeError: Request failed

孤者浪人 提交于 2019-12-04 23:12:17
I am creating a Progressive Web App for a university project, but when I checked the console I have this error: Uncaught (in promise) TypeError: Request failed - serviceworker.js:1 I don't understand where this error is coming from. The HTML and CSS are showing on as expected, but when I do a PWA audit from the Chrome Dev Tools, it's showing these failures. They are 'no service worker', 'no 200 when offline' and 'user not prompted to install web app'. Any help is appreciated! Thanks in advance! *{ padding: 0; margin: 0; font-family: "Roboto", sans-serif; color: #4E5863; } .indexLogo{ height:

How to enable offline support when using HTML5 history api

不问归期 提交于 2019-12-04 22:02:23
What are the best practices (and how to go about doing it) to support offline mode when using html5 history api for url rewrites? For example, (hypothetically) I have a PWA SPA application at https://abc.xyz which has internationalization built in. So when I visit this link, the Vue router (which ideally could be any framework - vue, react, angular etc.) redirect me to https://abc.xyz /en . This works perfectly when I am online (ofcourse, the webserver is also handling this redirect so that app works even if you directly visit the said link). However, its a different story when I am offline.

Check Service worker installation progress from component (angular)

我与影子孤独终老i 提交于 2019-12-04 18:33:45
I have updated my angular app into PWA, since I need to preload all of the assets on the first launch (application have a lots of images, which are used for UI). That's why I would like to show some kind of spinner/loading bar during service worker install event and hide it when it's done. So first question - is it possible to handle this event from the component? I have found this example and tried to add it inside first component, that loads on app launch, but didn't get any logs. So probably it doesn't work that way. ngOnInit() { self.addEventListener('install', event => { this.log(

How to make Angular Universal and PWA work together?

若如初见. 提交于 2019-12-04 14:38:45
问题 I have a SSR Angular app which I am trying to transform into a PWA. I want it to be server-side rendered for SEO and for the "fast first rendering" that it provides. The PWA mode works fine when combined with SSR, but once the app is loaded, when we refresh it, the client index HTML file is loaded instead of the server-side rendered page. I have dug into the code of ngsw-worker.js and I saw this: // Next, check if this is a navigation request for a route. Detect circular // navigations by

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

How to run offline “Progressive Web Apps”?

旧时模样 提交于 2019-12-04 13:04:15
I am new in progressive Webs Apps development. I want to implement progressive webs app. So I have implemented one demo page and this page working fine with net connection but without network(In Offline) it is not working. I want to open my progressive website without any internet connection(offline). I have seen one link https://developers.google.com/web/fundamentals/getting-started/codelabs/offline/ . And I have implemented service worker javascript file. I will explain step by step: First Step : I am using web server chrome: Second Step: index.html // Register the service worker if

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

PWA icons are not used in iOS 11.3

我怕爱的太早我们不能终老 提交于 2019-12-04 09:57:12
问题 Now I'm testing PWA on iOS 11.3 and I use the manifest.json file below: { "name": "Maplat PWA Sample", "short_name": "Maplat PWA", "background_color": "#fc980c", "icons": [{ "src": "/Maplat/pwa/icon-96.png", "sizes": "96x96", "type": "image/png" },{ "src": "/Maplat/pwa/icon-144.png", "sizes": "144x144", "type": "image/png" },{ "src": "/Maplat/pwa/icon-192.png", "sizes": "192x192", "type": "image/png" },{ "src": "/Maplat/pwa/icon-256.png", "sizes": "256x256", "type": "image/png" }], "start_url

How can I use NFC to redirect to or open my Progressive Web App?

人盡茶涼 提交于 2019-12-04 09:45:28
问题 I've got a progressive web app, app.example.com created using Chrome's "Add to Home Screen" button on Android. I have an NFC tag that ordinarily opens app.example.com/nfc_app in Chrome when it's tapped. How can I make it so that this NFC tag opens up the app.example.com/nfc_app PWA instead of Chrome when tapped? 回答1: Add a helper application as a work-around: package com.something; import android.content.Intent; import android.net.Uri; import android.nfc.NfcAdapter; import android.support