Skip to main content

Capacitor SDK Reference

The Live Updates API offers programmatic access to the Live Updates SDK and the most control over the user experience.

Within your Capacitor app project, install the Live Updates SDK:

npm install @capacitor/live-updates
npx cap sync

With the Live Updates SDK installed, add a "LiveUpdates" configuration section under plugins in capacitor.config.ts (or capacitor.config.json) file. Set autoUpdateMethod to none to use the SDK API:

import { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
plugins: {
LiveUpdates: {
appId: '042a1261',
channel: 'Production',
autoUpdateMethod: 'none',
maxVersions: 3
}
}
};

export default config;

The Capacitor SDK intentionally launched with less API operations than the Cordova SDK. Feel something is missing or have additional feedback? Please reach out to the Appflow team.

Sync

  • sync(): void
  • Description: Check for and download a new live update if available.
  • Returns: Promise<SyncResult>. A response describing a live update if one is available.

SyncResult Interface

  • activeApplicationPathChanged: boolean - true if a new live update has just been downloaded
  • liveUpdate.appId: string - Appflow App Id
  • liveUpdate.channel: string - Live Update channel name that the update has been deployed to
  • snapshot.buildId: string - Appflow Build Id
  • snapshot.id: string - Internal Appflow Id
  • source: string - download if a new live update has just been downloaded or cache if a cached live update has been found instead

Reload

  • reload(): void
  • Description: Reload the app. A new version will be shown afterward if available.
  • Returns: Promise<void>. Nothing.

Example

For more API usage examples, see Live Update Strategies.

import * as LiveUpdates from '@capacitor/live-updates';

// Check for new live update
const result = await LiveUpdates.sync();
// If active path has changed, then a new live update was downloaded
if (result.activeApplicationPathChanged) {
// Reload the app; the new version will appear afterward
await LiveUpdates.reload();
}