Skip to content

Manual Update

If you want to manage yourself when update is applied. Use manual mode with Capgo cloud.

Here is what you need to do, setup your account as explained in Geting Started.

Config

Disable auto-update in your capacitor.confg.json

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

Then add logic to handle updates yourself.
Here is an example on how you can do it:

import { CapacitorUpdater } from '@capgo/capacitor-updater'
import type { BundleInfo } from '@capgo/capacitor-updater'
import { SplashScreen } from '@capacitor/splash-screen'
import { App } from '@capacitor/app'
CapacitorUpdater.notifyAppReady()
let data: BundleInfo | null = null
App.addListener('appStateChange', async (state: any) => {
console.log('appStateChange', state)
if (state.isActive) {
console.log('getLatest')
// Do the download during user active app time to prevent failed downloads
const latest = await CapacitorUpdater.getLatest()
console.log('latest', latest)
if (latest.url) {
data = await CapacitorUpdater.download({
url: latest.url,
version: latest.version,
})
console.log('download', data)
}
}
if (!state.isActive && data) {
console.log('set')
// Do the switch when user leaves the app or when you want
SplashScreen.show()
try {
await CapacitorUpdater.set({ id: data.id })
}
catch (err) {
console.log(err)
SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
}
}
})

Documentation of all Available API in the plugin:

There are some usecase you can allow users to subscribe to channels and try different version:
https://capgo.app/blog/how-to-send-specific-version-to-users/