Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

Can you please explain how I can prompt the app user when a new version of my Ionic 4 PWA app is available?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

Hello,

You can add the message and the code to check the current / available versions to the JS file and set its network strategy "network first" https://blog.appery.io/2019/06/some-u... to see the latest version message every time the user opens the app.

Please pay attention, you have to republish the app every time you change this version

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

Hi Serhii, thank you but there is no example of the code needed to accomplish this.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

We are very sorry, but this is something outside the scope (https://docs.appery.io/docs/general-s...) of our standard support. I just said how it might be done with custom code.
You may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack (https://appery.io/services/#Advisory_...).

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

Really... I have to wait 2 days for this "outside the scope" reply

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

How would I display a "new version available" message for a PWA inside my Ionic 4 app?

For the rest of the community, this is what I did. I'm sure it can be done better by some code ninja.

codeif ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js')
.then(registration => {
//console.log(registration);
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
Swal.fire({
title: "Notice",
icon: 'info',
html: "New content is available. Please refresh by closing and opening the app.",
confirmButtonText: 'Close',
confirmButtonColor: '#BFE222'
})
} else {
console.log('Content is cached for offline use.');
}
}
};
};
})
.catch(err => console.error('Error', err));
}/code

Return to “Issues”