Skip to content

Best Practices

Here are some best practices to follow when using the Live Update SDK to ensure a smooth user experience.

Enable Automatic Rollbacks

The Live Update SDK supports automatic rollbacks in case an invalid bundle is provided. To enable this feature, you first need to configure the readyTimeout configuration option in your Capacitor project. This option specifies the maximum amount of time to wait for the app to be ready before rolling back to the built-in app bundle.

capacitor.config.ts
import { CapacitorConfig } from "@capacitor/cli";

const config: CapacitorConfig = {
  plugins: {
    LiveUpdate: {
      readyTimeout: 10000
    }
  }
};

export default config;
capacitor.config.json
{
  "plugins": {
    "LiveUpdate": {
      "readyTimeout": 10000
    }
  }
}

We recommend setting the readyTimeout to a value that balances user experience and the need for timely updates. A value of 10,000 milliseconds (10 seconds) is a good starting point. The app now has a maximum of 10 seconds to call the ready() method before the SDK rolls back to the built-in app bundle.

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

const initializeApp = async () => {
  await LiveUpdate.ready();
  // Call `LiveUpdate.ready()` before any other methods, e.g.:
  // await LiveUpdate.sync();
};

Make sure to call the ready() method as early as possible in your app's lifecycle to ensure the SDK is properly initialized and ready to handle updates.

Do Not Check for Updates Too Frequently

While it's important to keep your app up-to-date, checking for updates too frequently can lead to a poor user experience. Not only does the device get rate-limited after a certain number of requests, but these requests also use up a lot of the device's resources (battery, bandwidth, etc.).

You should definitely NOT check for updates in fixed intervals, such as every few seconds:

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

// Do NOT do this!!!
setTimeout(() => {
  LiveUpdate.checkForUpdate();
}, 60000);

Instead, we recommend implementing a reasonable update strategy that balances the need for timely updates with the overall user experience. Check out the Always Latest Update Strategy for an example of how to achieve this.