Auto update
This mode allows developers to use capacitor-updater with auto-update mode and push updates via CodePushGo channels or equivalent.
Prerequisites
Make sure your app version uses https://semver.org/ before using CodePushGo auto-update.
This is the convention it uses to manage versions in CodePushGo.
There are two ways to set the version in your app:
New way: Use the version field in your capacitor.config.json file.
{ "plugins": { "CapacitorUpdater": { "autoUpdate": "atBackground", // Enable auto-update, true keeps this same behavior "appId": "com.example.app", // Used to identify the app in the server "version": "1.0.0" // Used to check for updates } }}These options will be used by the plugin to check for updates, and the CLI to upload the version.
Old way: In 3 files in your project:
package.jsonin versionandroid/app/build.gradlein versionNameios/App/App.xcodeproj/project.pbxprojin CURRENT_PROJECT_VERSION
Tutorials
Setup your app in 5 mins
Update your capacitor apps seamlessly using capacitor updater
Setup your CI in 5 mins
Automatic build and release with GitHub actions
Install
npm install @capgo/capacitor-updaternpx cap syncIntro
Click on register to create your account.
The server allows you to manage channels and versions and much more.
autoUpdate will use data from capacitor.config to identify the CodePushGo server
Validate version
When auto-update is set up you have to notify from within JS that your app is alive and ready.
This can be done by calling within your app notifyAppReady.
Do it as soon as possible.
import { CapacitorUpdater } from '@capgo/capacitor-updater'
CapacitorUpdater.notifyAppReady()User flow
- User opens the app, the app calls the server to check for updates, if any are found theyβll be downloaded in the background.
- User leaves the app, the new version is set as active.
- User opens app again, we load the new active version and set it as default.
- If
notifyAppReady()is called, when the user leaves the app, the past version is deleted. - User continues normal flow of the app until next update cycle.
Dev flow
When you develop new features, be sure to block autoUpdate, as CodePushGo will constatly overwrite your work with the latest update bundle.
Set autoUpdate to "off" in your config.
If for some reason you are stuck on an update, you can delete the app and reinstall it.
Be sure to set autoUpdate to "off" in your config before doing so.
And then build it again with Xcode or Android studio.
To upload the version at each commit setup CI/CD with this guide
Automatic build and release with GitHub actions
Major Available event
When disableAutoUpdateBreaking is set to true, you can listen to the event to know when the app refuses to do a major braking update.
import { CapacitorUpdater } from '@capgo/capacitor-updater'
CapacitorUpdater.addListener('majorAvailable', (info: any) => { console.log('majorAvailable was fired', info.version)})