Migrating from Cordova to Capacitor-based SDK
Regardless of the product you use with Live Updates, it’s easy to migrate to Capacitor-based Live Updates SDK and/or native libraries. The Capacitor-based Live Updates SDK relies on a new manifest differentials file, live-update-manifest.json. For reference, the Cordova SDK leverages a pro-manifest.json manifest file. Appflow now builds both manifest files in order to provide a seamless transition to your end users.
Cordova or Capacitor app
Perhaps unsurprisingly, the new Capacitor-based Live Updates SDK, @capacitor/live-updates, requires Capacitor. First, remove the Cordova cordova-plugin-ionic from your project.
npm uninstall cordova-plugin-ionic
If you're working in a Capacitor project already, remove any Cordova Live Updates-related preferences from capacitor.config.ts:
"cordova": {
"preferences": {
"DisableDeploy": "true"
}
}
Finally, sync the project to remove the SDK and configuration from the native projects.
npx cap sync
Next, remove the following Cordova SDK configuration variables from the iOS project in ios/App/App/Info.plist:
<key>IonAppId</key>
<string>YOUR_APP_ID</string>
<key>IonChannelName</key>
<string>CHANNEL_NAME</string>
<key>IonUpdateMethod</key>
<string>background</string>
<key>IonMaxVersions</key>
<string>2</string>
<key>IonMinBackgroundDuration</key>
<string>30</string>
<key>IonApi</key>
<string>https://api.ionicjs.com</string>
For reference, the Capacitor SDK writes configuration values here: ios/App/App/capacitor.config.json.
Next, remove the following Cordova SDK configuration variables from the Android project in android/app/src/main/res/values/strings.xml:
<string name="ionic_app_id">YOUR_APP_ID</string>
<string name="ionic_channel_name">CHANNEL_NAME</string>
<string name="ionic_update_method">background</string>
<string name="ionic_max_versions">2</string>
<string name="ionic_min_background_duration">30</string>
<string name="ionic_update_api">https://api.ionicjs.com</string>
For reference, the Capacitor SDK writes configuration values here: android/app/src/main/assets/capacitor.config.json.
With the Cordova SDK removed, migrate to Capacitor. Next, install and configure the Capacitor SDK see install details. Finally, a new app store binary release is required because of the SDK change. Ensure the latest web code/build is included in the native binary. Enjoy!
Since Appflow supports and ships both manifest files in a Live Update, your users won’t notice or be disrupted during the transition. If they are using a native binary with the Cordova SDK installed, the pro-manifest.json file will be used. If they update the native app and now have the Capacitor SDK installed, it will use the live-update-manifest.json file instead when applying a new live update.
SDK Configuration Differences
| Option | cordova-plugin-ionic | @capacitor/live-updates | Notes |
|---|---|---|---|
| Config file | config.xml | capacitor.config.ts | SDK configuration file. |
| Live Updates manifest file | pro-manifest.json | live-update-manifest.json | See Manifest file details. |
| App Id | app-id | appId | Id representing an Appflow App. |
| Channel | channel-name | channel | The channel from which the device will receive updates. |
| Max Versions | max-versions | maxVersions | Number of previous updates to cache on user's device. |
| Update Method/Strategy | background, auto, none | background, none | More options are available. View Live Updates strategies. |
| Strategy algorithm | n/a | strategy (zip, differential) | Whether the live update is a zip file or uses differentials. |
| Code Signing | n/a | key | The public key used for code signing in self-hosted live updates. |
| Min Background Duration | min-background-duration | n/a | The number of seconds the app needs to be in the background for it to have been considered "closed." |
| Turn off live updates for development | DisableDeploy (true) | enabled (false) | Your code will get overwritten if the local app codebase points to the same channel as a deployed Live Update build. |
Self-hosted Live Updates
- Update to latest version of capacitor/live-updates:
npm i @capacitor/live-updates@latest - Ensure you’re on the latest version of the Appflow CLI that supports differentials: v0.14.5 and up
- Follow the updated guide to setting up SHLU, this part: https://ionic.io/docs/appflow/deploy/setup/self-hosted#self-hosted