Zum Inhalt springen

Auto update

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

This mode allows developers to use capacitor-updater with auto-update mode and push updates via Capgo channels or equivalent.

Prerequisites

Make sure your app version uses https://semver.org/ before using Capgo auto-update.

This is the convention it uses to manage versions in Capgo.

There is 2 way to set version in your app:

New way: Use the version field in your capacitor.config.json file.

{
"plugins": {
"CapacitorUpdater": {
"autoUpdate": true, // Enable auto-update, true by default
"appId": "com.example.app", // Used to identify the app in the server
"version": "1.0.0" // Used to check for updates
}
}
}

This will option in CapacitorUpdater 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.json in version
  • android/app/build.gradle in versionName
  • ios/App/App.xcodeproj/project.pbxproj in 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

Terminal window
npm install @capgo/capacitor-updater
npx cap sync

Intro

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 Capgo 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 capgo will constatly overwrite your work with the latest update bundle. Set autoUpdate to false 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 false 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)
})