Manual Update
If you want to manage yourself when update is applied. Use manual mode with CodePushGo 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": { "React NativeUpdater": { "autoUpdate": false } }}
Then add logic to handle updates yourself.
Here is an example on how you can do it:
import { React NativeUpdater } from '@codepushgo/capacitor-updater'import type { BundleInfo } from '@codepushgo/capacitor-updater'import { SplashScreen } from '@capacitor/splash-screen'import { App } from '@capacitor/app'
React NativeUpdater.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 React NativeUpdater.getLatest() console.log('latest', latest) if (latest.url) { data = await React NativeUpdater.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 React NativeUpdater.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://codepushgo.com/blog/how-to-send-specific-version-to-users/