You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store the information about the latest version of the App onto Firebase Realtime Database. Make sure that you update the latest version information on the Firebase, only after your app is deployed successuflly.
Embed the current release (version) detail with your app. e.g. index.html.
Install Workbox as follows:
import{defaultasinstallWorkbox}from'@dreamworld/workbox-installer';importFirebaseLatestVersionUpdateCheckerfrom'@dreamworld/workbox-installer/firebase-latest-version-update-checker.js';constappCurVersion='1.0.0';//This might be read from one of the configuration, in the real implementationinstallWorkbox({url: '/service-worker.js',confirmUpdate: (latestVersion)=>{//Create a Promise & return it.//Show notification to your user//When user confirms, resolve the promise.},updateChecker: newFirebaseLatestVersionUpdatechecker({
fbDatabase,latestVersionPath: '/app/latestVersion',curVersion: appCurVersion})});
How does this work?
It will watch the Firebase Realtime Database on the latestVersionPath.
As soon as it finds that the curVersion isn't same as the latest version, it notifies the installer to check for the updates.
It sends value of the latest version (as a String), as the updates to the installer.
So, confirmUpdate function may use the latestVersion to print it into notification.