Skip to content

Advanced Usage

If you want more control over the update process, you can use the following methods:

  1. fetchLatestBundle(): Check for updates without downloading them.
  2. downloadBundle(): Download updates without applying them.
  3. setNextBundle(): Set a new bundle as the next bundle to be applied.
  4. reload(): Apply the new bundle immediately.

Disable Automatic Updates

If you are manually handling the update process, it is strongly recommended to set the autoUpdateStrategy configuration option to none to prevent conflicts with the automatic update mechanism.

Check for updates

You can check for new bundles without downloading them by using the fetchLatestBundle() method:

import { LiveUpdate } from "@capawesome/capacitor-live-update";

const checkForUpdates = async () => {
  const result = await LiveUpdate.fetchLatestBundle();
  if (result.bundleId) {
    console.log("New update available: " + result.downloadUrl);
  } else {
    console.log("No update available");
  }
};

This method returns all important information about the latest bundle, including the bundle ID and the download URL.

Download updates

You can then download bundles by using the downloadBundle() method:

import { LiveUpdate } from "@capawesome/capacitor-live-update";

const downloadUpdate = async (bundleId: string, url: string) => {
  await LiveUpdate.downloadBundle({
    bundleId,
    url
  });
};

This method downloads the bundle, extracts the files, and moves them to the correct location in your app.

Apply updates

You can set a new bundle as the next bundle to be applied by using the setNextBundle() method:

import { LiveUpdate } from "@capawesome/capacitor-live-update";

const setNextBundle = async (bundleId: string) => {
  await LiveUpdate.setNextBundle({
    bundleId,
  });
};

If the bundle should be applied immediately, you can also call the reload() method:

import { LiveUpdate } from "@capawesome/capacitor-live-update";

const reload = async () => {
  await LiveUpdate.reload();
};