From V3 to V4
此内容尚不支持你的语言。
Why this upgrade
After many talk in the discord community with you. I discovered the manual mode was very too manual and not safe to use, for example, auto-revert was not possible, so if you failed update in manual the user have to remove the app and install back, what is terrible UX.
Meanwhile, I took this as an opportunity to give more freedom to you, and remove all bad code I made.
Install
npm i @capgo/capacitor-updater@4
Auto-update cloud
If you use the basic example in your app, you are safe to migrate to the new version, enjoy!
Auto-update self-hosted
For you, still simple, the changes are:
- The name of the setting from
autoUpdateUrlinupdateUrl - The Endpoint method changed from
GETto POST
Manual users
For you, this is the most significant change, but for the best! You get tons of improvements, Read carefully.
Changes
autoUpdateUrlbecomesupdateUrlsince this setting can be used in manual mode now too- Delete of
cancelDelayanddelayUpdatein favor ofsetDelay - No more
versionNamein set - Change
versionkey, who was returned in most function to objectBundleInfo
interface BundleInfo { id: string; version: string; downloaded: string; status: 'success' | 'error' | 'pending' | 'downloading'}- Renamed of misleading names now (even to explain cannot be clear, but at usage is easy to understand the new one):
- what was called a
versionis now referring to abundle idrefer to the oldversionwho was a random string of 10 char, thisidis the only trustable and unique way to access to your bundles, example7Dfcd2RedN.versionrefer now to theversionNameyou choose for a bundle, example1.0.0
- what was called a
updateUrlmove fromgettopost, since custom headers were a problem for some of you and post is more logical, all previous headers go to the body and prefixcap_disappear.versionNamemethod is deleted, in favor ofgetId- list returns now a list of
BundleInfo - Rename
getIdingetDeviceId autoUpdatebecomes true by default, if you use Manual mode, set it to false.
News
- Method
getLatest, this method allows you to get from your server set withupdateUrlthe last version available. - Method
setDelaywho take{kind:“background” | “kill” | “nativeVersion” | “date”, value? : string}as argument to set delay to different modes. - Method
next, to set the version in next backgrounding, in opposite tosetwho do it instantly. - Method
isAutoUpdateEnabled, to let you know if you are in auto-update context - Event
downloadCompletewhen download reach 100% - Added mandatory field
versionin download method notifyAppReadybecome mandatory in manual mode too, if not call after 10 sec the app reverts to past version.
Contributors
@lincolnthree Thank you so much for starting this work, it was impossible to make this update work without you.