Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
capacitor-updater
Advanced tools
Readme
Update capacitor app without store review.
You have 3 ways possible :
Join the discord to get help.
I maintain a more user friendly and complete documentation in GitHub wiki.
npm install @capgo/capacitor-updater
npx cap sync
Create account in capgo.app and get your API key
npx @capgo/cli login API_KEY
npx @capgo/cli add
npx @capgo/cli upload -c production
npx @capgo/cli set -c production -s public
capacitor.config.json
like below, set autoUpdate
to true.// capacitor.config.json
{
"appId": "**.***.**",
"appName": "Name",
"plugins": {
"CapacitorUpdater": {
"autoUpdate": true,
}
}
}
import { CapacitorUpdater } from '@capgo/capacitor-updater'
CapacitorUpdater.notifyAppReady()
// To let auto update know you app boot well.
npm run build && npx cap copy
to copy the build to capacitor.See more there in the Auto update documentation.
Download app update from url when user enter the app install it when user background the app.
In your main code :
import { CapacitorUpdater } from '@capgo/capacitor-updater'
import { SplashScreen } from '@capacitor/splash-screen'
import { App } from '@capacitor/app'
let version = ""
App.addListener('appStateChange', async(state) => {
if (state.isActive) {
// Do the download during user active app time to prevent failed download
version = await CapacitorUpdater.download({
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
})
}
if (!state.isActive && version !== "") {
// Do the switch when user leave app
SplashScreen.show()
try {
await CapacitorUpdater.set(version)
} catch () {
SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
}
}
})
// or do it when click on button
const updateNow = async () => {
const version = await CapacitorUpdater.download({
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
})
// show the splashscreen to let the update happen
SplashScreen.show()
await CapacitorUpdater.set(version)
SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
}
Be extra careful for your update if you send a broken update, the app will crash until the user reinstalls it.
If you need more secure way to update your app, you can use Auto update system.
You can list the version and manage it with the command below.
dist.zip
Whatever you choose to name the file you download from your release/update server URL, the zip file should contain the full contents of your production Capacitor build output folder, usually {project directory}/dist/
or {project directory}/www/
. This is where index.html
will be located, and it should also contain all bundled JavaScript, CSS, and web resources necessary for your app to run.
Do not password encrypt this file, or it will fail to unpack.
download(...)
set(...)
getId()
getPluginVersion()
delete(...)
list()
reset(...)
current()
reload()
versionName()
notifyAppReady()
delayUpdate()
cancelDelay()
addListener('download', ...)
addListener('majorAvailable', ...)
addListener('updateAvailable', ...)
addListener(string, ...)
removeAllListeners()
download(options: { url: string; }) => Promise<{ version: string; }>
Download a new version from the provided URL, it should be a zip file, with files inside or with a unique folder inside with all your files
Param | Type |
---|---|
options | { url: string; } |
Returns: Promise<{ version: string; }>
set(options: { version: string; versionName?: string; }) => Promise<void>
Set version as current version, set will return an error if there are is no index.html file inside the version folder. versionName
is optional and it's a custom value that will be saved for you
Param | Type |
---|---|
options | { version: string; versionName?: string; } |
getId() => Promise<{ id: string; }>
Get unique ID used to identify device into auto update server
Returns: Promise<{ id: string; }>
getPluginVersion() => Promise<{ version: string; }>
Get plugin version used in native code
Returns: Promise<{ version: string; }>
delete(options: { version: string; }) => Promise<void>
Delete version in storage
Param | Type |
---|---|
options | { version: string; } |
list() => Promise<{ versions: string[]; }>
Get all available versions
Returns: Promise<{ versions: string[]; }>
reset(options?: { toAutoUpdate?: boolean | undefined; } | undefined) => Promise<void>
Set the builtin
version (the one sent to Apple store / Google play store ) as current version
Param | Type |
---|---|
options | { toAutoUpdate?: boolean; } |
current() => Promise<{ current: string; currentNative: string; }>
Get the current version, if none are set it returns builtin
, currentNative is the original version install on the device
Returns: Promise<{ current: string; currentNative: string; }>
reload() => Promise<void>
Reload the view
versionName() => Promise<{ versionName: string; }>
Get the version name, if it was set during the set phase
Returns: Promise<{ versionName: string; }>
notifyAppReady() => Promise<void>
Notify native plugin that the update is working, only in auto-update
delayUpdate() => Promise<void>
Skip updates in the next time the app goes into the background, only in auto-update
cancelDelay() => Promise<void>
allow update in the next time the app goes into the background, only in auto-update
addListener(eventName: 'download', listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for download event in the App, let you know when the download is started, loading and finished
Param | Type |
---|---|
eventName | 'download' |
listenerFunc | DownloadChangeListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.0.11
addListener(eventName: 'majorAvailable', listenerFunc: MajorAvailableListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for Major update event in the App, let you know when major update is blocked by setting disableAutoUpdateBreaking
Param | Type |
---|---|
eventName | 'majorAvailable' |
listenerFunc | MajorAvailableListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(eventName: 'updateAvailable', listenerFunc: UpdateAvailableListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for update event in the App, let you know when update is ready to install at next app start
Param | Type |
---|---|
eventName | 'updateAvailable' |
listenerFunc | UpdateAvailableListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 2.3.0
addListener(eventName: string, listenerFunc: (...args: any[]) => any) => Promise<PluginListenerHandle>
Param | Type |
---|---|
eventName | string |
listenerFunc | (...args: any[]) => any |
Returns: Promise<PluginListenerHandle>
removeAllListeners() => Promise<void>
Prop | Type |
---|---|
remove | () => Promise<void> |
Prop | Type | Description | Since |
---|---|---|---|
percent | number | Current status of download, between 0 and 100. | 2.0.11 |
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a new major version is available. | 2.3.0 |
Prop | Type | Description | Since |
---|---|---|---|
version | string | Emit when a new update is available. | 3.0.0 |
(state: DownloadEvent): void
(state: MajorAvailableEvent): void
(state: UpdateAvailableEvent): void
import { CapacitorUpdater } from '@capgo/capacitor-updater';
CapacitorUpdater.addListener('download', (info: any) => {
console.log('download was fired', info.percent);
});
On iOS, Apple don't allow you to show a message when the app is updated, so you can't show a progress bar.
jamesyoung1337 Thanks a lot for your guidance and support, it was impossible to make this plugin work without you.
FAQs
OTA update for capacitor apps
The npm package capacitor-updater receives a total of 240 weekly downloads. As such, capacitor-updater popularity was classified as not popular.
We found that capacitor-updater demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.