コンテンツにスキップ

Introduction - Auto Update

このコンテンツはまだ日本語訳がありません。

This documentation will explain how to run your auto-update server.

Before start

If you use this work on your own, I couldn’t suggest more to support my work through this.

I made a big bet to open source all the precious code I built here.

I could have kept it for myself and put a high ticket price.

Furthermore, I want to focus on Capgo tooling and make it an open and transparent business.

Likewise, I do think it would make our world a better place by opening instead of fighting and hiding.

But to make it possible, all of us must do our part, including you 🥹.

If capgo offers can’t suit you, then put your price and back a bootstrapped Maker HERE on your terms.

Quick installs

npm install @capgo/capacitor-updater
npx cap sync

Configuration

You have to configure the plugin to use your URL like that:

{
"plugins": {
"CapacitorUpdater": {
"updateUrl": "https://YOURURL",
}
}
}

🚧 In android it’s not allowed to request to HTTP, for testing purposes allow it

Update API

The plugin will do a POST call to your API each time the app is open, with this body:

interface AppInfos {
"platform": "ios" | "android",
"device_id": "UUID_of_device_unique_by_install",
"app_id": "APPID_FROM_CAPACITOR_CONFIG",
"custom_id": "your_custom_id_set_on_runtime",
"plugin_version": "PLUGIN_VERSION",
"version_build": "VERSION_NUMBER_FROM_NATIVE_CODE",
"version_code": "VERSION_CODE_FROM_NATIVE_CODE",
"version_name": "LAST_DOWNLOADER_VERSION" | "builtin"
"version_os": "VERSION_OF_SYSYEM_OS",
"is_emulator": boolean,
"is_prod": boolean,
}

The server API should respond, in JSON, to the capacitor-updater plugin. With this data if an update is necessary:

{
"version": "1.2.3",
"url": "https://path_to_the_zip_file_of_the_code.com"
}

In Auto-update the server should do the work of comparing the version and return the right one, if the URL key is present, the plugin starts the download process.

If you add “message” and “error” key, the version will not be set, and the message will be displayed in logs instead.

version key should be in semver format.

The zip should have index.html as a file at the root, or only one folder at the root with index.html inside.

You can use the command of the CLI to zip your bundle:

Terminal window
npx @capgo/cli bundle zip --path [/path/to/my/bundle]

End-to-end Encryption

Starting with version 4.15.0 the plugin allows you to send encrypted updates.

You can use this feature by creating a private key npx @capgo/cli key create

Then you encrypt your zip file with npx @capgo/cli encrypt [path/to/zip]

The command will print you a ivSessionKey it has to be sent with your update payload in the key session_key.
Then your app will be able to use the private key to decrypt the session_key and use the decrypted session_key to decrypt the update.

Learn more about it here:

Statistics API

Starting from version 1.3.0 the update system sends stats!

By default, all stats are sent to our server, to understand usage.

💡 No private data is sent for stats, only random UUID, version update, version native app, platform, action, and app ID.

If you want to send data to your server instead, change the config below:

// capacitor.config.json
{
"appId": "**.***.**",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"statsUrl": "YOUR_URL"
}
}
}

What your server will receive is :

interface AppInfosStats {
"action": "set", // can be set, delete, set_fail, reset, revert
// Then it's the same info as update
"app_id": "**.***.**", // app identifier in the store
"device_id": "*******", // unique id per app install
"platform": "ios", // or android
"custom_id": "user_1", // represent your user
"version_name": "1.2.3", // version of the web build
"version_build": "1.2.0", // version of the native build
"version_code": "120", // build number of the native build
"version_os": "16", // OS version of the device
"plugin_version": "4.0.0"// to make your api behave differently with different plugins
"is_emulator": false,
"is_prod": false,
}

You can also totally disable it, with an empty string. Keep in mind, statistics are made private friendly and help me to understand how people use the plugin, to resolve issues and improve it.

Channel API

To be documented