GeoLeaf Core API - v3.19.0
    Preparing search index...

    Variable PWAManagerConst

    PWAManager: {
        init(config: PWAConfig): void;
        isInstallable(): boolean;
        isUpdateWaiting(): boolean;
        applyUpdate(): boolean;
        _reset(): void;
    } = ...

    GeoLeaf PWA Manager. Initializes the appropriate install prompt experience based on the platform.

    Type Declaration

    • init: function
      • Initializes the PWA install prompt for the current platform.

        • Opt-in: does nothing unless config.installPrompt.enabled === true.
        • iOS Safari: displays a bottom sheet with manual install instructions.
        • Other browsers: listens for beforeinstallprompt and shows a custom banner.

        Call this method after the GeoLeaf config has been loaded (i.e. from app/boot.ts).

        Parameters

        • config: PWAConfig

          PWA section from the loaded geoleaf.config.json.

        Returns void

    • isInstallable: function
      • true when the app can still be installed on this device — for integrators who want to render their own install button instead of (or alongside) the built-in banner.

        Mirrors the platform split of PWAManager.init:

        • iOS Safari — never fires beforeinstallprompt; answers from the UA + navigator.standalone check (installable = iOS and not already installed).
        • Android / Chrome / Edge — answers true once the browser has handed us a deferred beforeinstallprompt event.

        ⚠️ On Android this reports "a prompt is available", not "the browser could install this app": the deferred event is only captured if PWAManager.init has run, which is gated on modules.pwa.installPrompt.enabled === true. With the prompt disabled, it answers false even on an installable Chrome. iOS is unaffected — its check needs no listener.

        Returns boolean

        true if an install path is available right now.

    • isUpdateWaiting: function
      • true when a newer version of the application is installed and this page has not been reloaded onto it.

        A new service worker no longer takes a page that is in use: it waits, and geoleaf:sw:update-waiting says so. This reads the same fact at any time — a listener set after the boot may have missed the event. It also answers true when the update was applied from another tab: the worker changed under this page, which still runs the previous version's code.

        Always false at a first install, when modules.pwa.enabled is not true, and before the service worker has been registered (it is registered at idle, up to three seconds after the boot).

        Returns boolean

        true if PWAManager.applyUpdate has something to apply.

        document.addEventListener("geoleaf:sw:update-waiting", showMyReloadButton);
        if (GeoLeaf?.PWA?.isUpdateWaiting?.()) showMyReloadButton();
    • applyUpdate: function
      • Applies the waiting update: the new service worker takes over, and the page reloads once it does.

        Call it from a user gesture — unsaved input in the page is lost with the reload. Captures already queued by the offline write cycle are not: they live in IndexedDB. The reload is not instantaneous: the browser lets the new worker take over once the previous one has finished the requests it is serving, and the page reloads then — once.

        ⚠️ Without this call the new version stays installed and unused until every tab of the application is closed. The offline plugin calls it from its « Reload » banner; an application that does not embed that plugin has to offer the gesture itself.

        Returns boolean

        true when an update is being applied — the page will reload; false when nothing was waiting, and nothing happens.

        myReloadButton.addEventListener("click", () => GeoLeaf?.PWA?.applyUpdate?.());
        
    • _reset: function
      • Registry destroy / test seam: tears down both install sub-flows (the Android install-prompt global listeners and the iOS banner timer/banner) so a re-init starts clean (no listener / timer leak).

        Returns void