Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.44 KB

firebase-latest-version-update-checker.md

File metadata and controls

34 lines (28 loc) · 1.44 KB

FirebaseLatestVersionUpdateChecker

Usage

  • 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 { default as installWorkbox } from '@dreamworld/workbox-installer';
import FirebaseLatestVersionUpdateChecker from '@dreamworld/workbox-installer/firebase-latest-version-update-checker.js';

const appCurVersion = '1.0.0'; //This might be read from one of the configuration, in the real implementation

installWorkbox({
  url: '/service-worker.js', 
  confirmUpdate: (latestVersion) => {
    //Create a Promise & return it.
    //Show notification to your user
    //When user confirms, resolve the promise.
  },
  updateChecker: new FirebaseLatestVersionUpdatechecker({
    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.