Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Progressive Web App on iOS 12.2 stuck in offline page

I installed a custom progressive web app via safari and its "Add to Home Screen" option.

If I navigate to a specific page without an internet connection I get the native offline page of safari, as expected. The page shows the following message:

Safari cannot open the page because your iPhone is not connected to the Internet.

If I turn the internet connection on again, the PWA still shows the native safari offline page, giving the user no possibility to reload the page or navigate to another page.

To put in a nutshell, if I access my PWA without an internet connection once, the PWA shows native offline page of safari forever.

Is this the expected behavior of progressive web applications on iOS 12.2?

My service worker looks like this:

self.addEventListener('fetch', (evt) => {
    return;
});

Even if I serve a custom offline page as described in this article, the PWA is still stuck on the offline page, if I turn on my internet connection again.

like image 420
pragmaticus Avatar asked May 05 '19 14:05

pragmaticus


1 Answers

That is the expected behaviour when there is no default offline fallback page. Instead, I'd recommend creating a proper offline fallback page. There's a complete sample you can copy/paste in Create an offline fallback page.

It includes the service worker code you need, and a basic offline page that will attempt to reload the page once the network or server is back. You can see a working demo at https://basic-pwa.glitch.me/

like image 167
PeteLe Avatar answered Nov 14 '22 12:11

PeteLe