@capgo/capacitor-updater 3.0.10 → 3.2.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -130
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +130 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleStatus.java +36 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdater.java +403 -275
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +485 -268
- package/dist/docs.json +512 -109
- package/dist/esm/definitions.d.ts +201 -69
- package/dist/esm/web.d.ts +21 -16
- package/dist/esm/web.js +29 -23
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +29 -23
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +29 -23
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/BundleInfo.swift +94 -0
- package/ios/Plugin/BundleStatus.swift +41 -0
- package/ios/Plugin/CapacitorUpdater.swift +348 -84
- package/ios/Plugin/CapacitorUpdaterPlugin.m +4 -2
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +277 -166
- package/ios/Plugin/ObjectPreferences.swift +97 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# capacitor-updater
|
|
2
2
|
|
|
3
|
-
Update
|
|
3
|
+
Update Ionic Capacitor apps without App/Play Store review (Code-push / hot-code updates).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- use [capgo.app](https://capgo.app) a full featured auto update system
|
|
7
|
-
-
|
|
8
|
-
- use manual methods to zip, upload, download, from
|
|
5
|
+
Usage options:
|
|
6
|
+
- use [capgo.app](https://capgo.app), a full featured auto update system. (5 min Setup, easily manage versions, update, revert, and see detailed stats.)
|
|
7
|
+
- integrate your own API with this plugin's auto update system.
|
|
8
|
+
- use manual methods to zip, upload, download, from application code - you have full control.
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
## Community
|
|
@@ -14,17 +14,17 @@ Join the [discord](https://discord.gg/VnYRvBfgA6) to get help.
|
|
|
14
14
|
## Documentation
|
|
15
15
|
I maintain a more user friendly and complete [documentation](https://github.com/Cap-go/capacitor-updater/wiki) in GitHub wiki.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
npm install @capgo/capacitor-updater
|
|
21
21
|
npx cap sync
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
## Auto
|
|
24
|
+
## Auto-update setup
|
|
25
25
|
|
|
26
26
|
Create account in [capgo.app](https://capgo.app) and get your [API key](https://capgo.app/app/apikeys)
|
|
27
|
-
- Download the CLI `npm i -g capgo`
|
|
27
|
+
- Download the CLI `npm i -g @capgo/cli`
|
|
28
28
|
- Add app from CLI `capgo add -a API_KEY`
|
|
29
29
|
- Upload app `capgo upload -a API_KEY`
|
|
30
30
|
- Upload app `capgo set -a API_KEY -s public`
|
|
@@ -43,93 +43,97 @@ Create account in [capgo.app](https://capgo.app) and get your [API key](https://
|
|
|
43
43
|
```
|
|
44
44
|
- Add to your main code
|
|
45
45
|
```javascript
|
|
46
|
-
import { CapacitorUpdater } from 'capacitor-updater'
|
|
46
|
+
import { CapacitorUpdater } from '@capgo/capacitor-updater'
|
|
47
47
|
CapacitorUpdater.notifyAppReady()
|
|
48
|
-
// To let auto update know you app boot well.
|
|
49
48
|
```
|
|
49
|
+
This tells Capacitor Updator that the current update bundle has loaded succesfully. Failing to call this method will cause your application to be rolled back to the previously successful version (or built-in bundle).
|
|
50
50
|
|
|
51
51
|
- Do `npm run build && npx cap copy` to copy the build to capacitor.
|
|
52
52
|
- Run the app and see app auto update after each backgrounding.
|
|
53
|
-
-
|
|
53
|
+
- Failed updates will automatically roll back to the last successful version.
|
|
54
54
|
|
|
55
|
-
See more
|
|
56
|
-
https://doc.capgo.app/Auto-update-2cf9edda70484d7fa57111ab9c435d08) documentation.
|
|
55
|
+
See more details in the [Auto update](https://github.com/Cap-go/capacitor-updater/wiki) documentation.
|
|
57
56
|
|
|
58
57
|
|
|
59
58
|
## Manual setup
|
|
60
59
|
|
|
61
|
-
Download
|
|
62
|
-
install it when user background the app.
|
|
63
|
-
|
|
64
|
-
In your main code :
|
|
60
|
+
Download update distribution zipfiles from a custom url. Manually control the entire update process.
|
|
65
61
|
|
|
62
|
+
- Add to your main code
|
|
63
|
+
```javascript
|
|
64
|
+
import { CapacitorUpdater } from '@capgo/capacitor-updater'
|
|
65
|
+
CapacitorUpdater.notifyAppReady()
|
|
66
|
+
```
|
|
67
|
+
This informs Capacitor Updator that the current update bundle has loaded succesfully. Failing to call this method will cause your application to be rolled back to the previously successful version (or built-in bundle).
|
|
68
|
+
- Add this to your application.
|
|
69
|
+
```javascript
|
|
70
|
+
const version = await CapacitorUpdater.download({
|
|
71
|
+
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
|
|
72
|
+
})
|
|
73
|
+
await CapacitorUpdater.set(version); // sets the new version, and reloads the app
|
|
74
|
+
```
|
|
75
|
+
- Failed updates will automatically roll back to the last successful version.
|
|
76
|
+
- Example: Using App-state to control updates, with SplashScreen:
|
|
77
|
+
You might also consider performing auto-update when application state changes, and using the Splash Screen to improve user experience.
|
|
66
78
|
```javascript
|
|
67
|
-
import { CapacitorUpdater } from 'capacitor-updater'
|
|
79
|
+
import { CapacitorUpdater, VersionInfo } from '@capgo/capacitor-updater'
|
|
68
80
|
import { SplashScreen } from '@capacitor/splash-screen'
|
|
69
81
|
import { App } from '@capacitor/app'
|
|
70
82
|
|
|
71
|
-
let version
|
|
72
|
-
App.addListener('appStateChange', async(state) => {
|
|
83
|
+
let version: VersionInfo;
|
|
84
|
+
App.addListener('appStateChange', async (state) => {
|
|
73
85
|
if (state.isActive) {
|
|
74
|
-
//
|
|
86
|
+
// Ensure download occurs while the app is active, or download may fail
|
|
75
87
|
version = await CapacitorUpdater.download({
|
|
76
|
-
|
|
88
|
+
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
|
|
77
89
|
})
|
|
78
90
|
}
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
|
|
92
|
+
if (!state.isActive && version) {
|
|
93
|
+
// Activate the update when the application is sent to background
|
|
81
94
|
SplashScreen.show()
|
|
82
95
|
try {
|
|
83
|
-
await CapacitorUpdater.set(version)
|
|
96
|
+
await CapacitorUpdater.set(version);
|
|
97
|
+
// At this point, the new version should be active, and will need to hide the splash screen
|
|
84
98
|
} catch () {
|
|
85
|
-
SplashScreen.hide() //
|
|
99
|
+
SplashScreen.hide() // Hide the splash screen again if something went wrong
|
|
86
100
|
}
|
|
87
101
|
}
|
|
88
102
|
})
|
|
89
103
|
|
|
90
|
-
// or do it when click on button
|
|
91
|
-
const updateNow = async () => {
|
|
92
|
-
const version = await CapacitorUpdater.download({
|
|
93
|
-
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
|
|
94
|
-
})
|
|
95
|
-
// show the splashscreen to let the update happen
|
|
96
|
-
SplashScreen.show()
|
|
97
|
-
await CapacitorUpdater.set(version)
|
|
98
|
-
SplashScreen.hide() // in case the set fail, otherwise the new app will have to hide it
|
|
99
|
-
}
|
|
100
104
|
```
|
|
101
105
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
If you need more secure way to update your app, you can use Auto update system.
|
|
105
|
-
|
|
106
|
-
You can list the version and manage it with the command below.
|
|
106
|
+
TIP: If you prefer a secure and automated way to update your app, you can use [capgo.app](https://capgo.app) - a full-featured, auto update system.
|
|
107
107
|
|
|
108
|
-
### Packaging `dist.zip`
|
|
108
|
+
### Packaging `dist.zip` update bundles
|
|
109
109
|
|
|
110
|
-
Whatever you choose to name the file you download from your release/update server URL
|
|
110
|
+
Capacitor Updator works by unzipping a compiled app bundle to the native device filesystem. Whatever you choose to name the file you upload/download from your release/update server URL (via either manual or automatic updating), this `.zip` bundle must meet the following requirements:
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
- 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.
|
|
113
|
+
- Do not password encrypt the bundle zip file, or it will fail to unpack.
|
|
114
|
+
- Make sure the bundle does not contain any extra hidden files or folders, or it may fail to unpack.
|
|
113
115
|
|
|
114
116
|
## API
|
|
115
117
|
|
|
116
118
|
<docgen-index>
|
|
117
119
|
|
|
120
|
+
* [`notifyAppReady()`](#notifyappready)
|
|
118
121
|
* [`download(...)`](#download)
|
|
122
|
+
* [`next(...)`](#next)
|
|
119
123
|
* [`set(...)`](#set)
|
|
120
|
-
* [`getId()`](#getid)
|
|
121
124
|
* [`delete(...)`](#delete)
|
|
122
125
|
* [`list()`](#list)
|
|
123
126
|
* [`reset(...)`](#reset)
|
|
124
127
|
* [`current()`](#current)
|
|
125
128
|
* [`reload()`](#reload)
|
|
126
|
-
* [`
|
|
127
|
-
* [`notifyAppReady()`](#notifyappready)
|
|
128
|
-
* [`delayUpdate()`](#delayupdate)
|
|
129
|
-
* [`cancelDelay()`](#canceldelay)
|
|
129
|
+
* [`setDelay(...)`](#setdelay)
|
|
130
130
|
* [`addListener('download', ...)`](#addlistenerdownload)
|
|
131
|
+
* [`addListener('downloadComplete', ...)`](#addlistenerdownloadcomplete)
|
|
131
132
|
* [`addListener('majorAvailable', ...)`](#addlistenermajoravailable)
|
|
132
|
-
* [`addListener('
|
|
133
|
+
* [`addListener('updateFailed', ...)`](#addlistenerupdatefailed)
|
|
134
|
+
* [`getId()`](#getid)
|
|
135
|
+
* [`getPluginVersion()`](#getpluginversion)
|
|
136
|
+
* [`isAutoUpdateEnabled()`](#isautoupdateenabled)
|
|
133
137
|
* [`addListener(string, ...)`](#addlistenerstring)
|
|
134
138
|
* [`removeAllListeners()`](#removealllisteners)
|
|
135
139
|
* [Interfaces](#interfaces)
|
|
@@ -140,47 +144,64 @@ Do not password encrypt this file, or it will fail to unpack.
|
|
|
140
144
|
<docgen-api>
|
|
141
145
|
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
142
146
|
|
|
147
|
+
### notifyAppReady()
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
notifyAppReady() => Promise<BundleInfo>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
|
|
154
|
+
|
|
155
|
+
**Returns:** <code>Promise<<a href="#bundleinfo">BundleInfo</a>></code>
|
|
156
|
+
|
|
157
|
+
--------------------
|
|
158
|
+
|
|
159
|
+
|
|
143
160
|
### download(...)
|
|
144
161
|
|
|
145
162
|
```typescript
|
|
146
|
-
download(options: { url: string; }) => Promise<
|
|
163
|
+
download(options: { url: string; version?: string; }) => Promise<BundleInfo>
|
|
147
164
|
```
|
|
148
165
|
|
|
149
|
-
Download a new version from the provided URL, it should be a zip file, with files inside or with a unique
|
|
166
|
+
Download a new version from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files
|
|
150
167
|
|
|
151
|
-
| Param | Type
|
|
152
|
-
| ------------- |
|
|
153
|
-
| **`options`** | <code>{ url: string; }</code> |
|
|
168
|
+
| Param | Type |
|
|
169
|
+
| ------------- | ----------------------------------------------- |
|
|
170
|
+
| **`options`** | <code>{ url: string; version?: string; }</code> |
|
|
154
171
|
|
|
155
|
-
**Returns:** <code>Promise<
|
|
172
|
+
**Returns:** <code>Promise<<a href="#bundleinfo">BundleInfo</a>></code>
|
|
156
173
|
|
|
157
174
|
--------------------
|
|
158
175
|
|
|
159
176
|
|
|
160
|
-
###
|
|
177
|
+
### next(...)
|
|
161
178
|
|
|
162
179
|
```typescript
|
|
163
|
-
|
|
180
|
+
next(options: { id: string; }) => Promise<BundleInfo>
|
|
164
181
|
```
|
|
165
182
|
|
|
166
|
-
Set
|
|
183
|
+
Set the next bundle to be used when the app is reloaded.
|
|
167
184
|
|
|
168
|
-
| Param | Type
|
|
169
|
-
| ------------- |
|
|
170
|
-
| **`options`** | <code>{
|
|
185
|
+
| Param | Type |
|
|
186
|
+
| ------------- | ---------------------------- |
|
|
187
|
+
| **`options`** | <code>{ id: string; }</code> |
|
|
188
|
+
|
|
189
|
+
**Returns:** <code>Promise<<a href="#bundleinfo">BundleInfo</a>></code>
|
|
171
190
|
|
|
172
191
|
--------------------
|
|
173
192
|
|
|
174
193
|
|
|
175
|
-
###
|
|
194
|
+
### set(...)
|
|
176
195
|
|
|
177
196
|
```typescript
|
|
178
|
-
|
|
197
|
+
set(options: { id: string; }) => Promise<void>
|
|
179
198
|
```
|
|
180
199
|
|
|
181
|
-
|
|
200
|
+
Set the current bundle and immediately reloads the app.
|
|
182
201
|
|
|
183
|
-
|
|
202
|
+
| Param | Type |
|
|
203
|
+
| ------------- | ---------------------------- |
|
|
204
|
+
| **`options`** | <code>{ id: string; }</code> |
|
|
184
205
|
|
|
185
206
|
--------------------
|
|
186
207
|
|
|
@@ -188,14 +209,14 @@ Get unique ID used to identify device into auto update server
|
|
|
188
209
|
### delete(...)
|
|
189
210
|
|
|
190
211
|
```typescript
|
|
191
|
-
delete(options: {
|
|
212
|
+
delete(options: { id: string; }) => Promise<void>
|
|
192
213
|
```
|
|
193
214
|
|
|
194
|
-
Delete
|
|
215
|
+
Delete bundle in storage
|
|
195
216
|
|
|
196
|
-
| Param | Type
|
|
197
|
-
| ------------- |
|
|
198
|
-
| **`options`** | <code>{
|
|
217
|
+
| Param | Type |
|
|
218
|
+
| ------------- | ---------------------------- |
|
|
219
|
+
| **`options`** | <code>{ id: string; }</code> |
|
|
199
220
|
|
|
200
221
|
--------------------
|
|
201
222
|
|
|
@@ -203,12 +224,12 @@ Delete version in storage
|
|
|
203
224
|
### list()
|
|
204
225
|
|
|
205
226
|
```typescript
|
|
206
|
-
list() => Promise<{
|
|
227
|
+
list() => Promise<{ bundles: BundleInfo[]; }>
|
|
207
228
|
```
|
|
208
229
|
|
|
209
230
|
Get all available versions
|
|
210
231
|
|
|
211
|
-
**Returns:** <code>Promise<{
|
|
232
|
+
**Returns:** <code>Promise<{ bundles: BundleInfo[]; }></code>
|
|
212
233
|
|
|
213
234
|
--------------------
|
|
214
235
|
|
|
@@ -216,14 +237,14 @@ Get all available versions
|
|
|
216
237
|
### reset(...)
|
|
217
238
|
|
|
218
239
|
```typescript
|
|
219
|
-
reset(options?: {
|
|
240
|
+
reset(options?: { toLastSuccessful?: boolean | undefined; } | undefined) => Promise<void>
|
|
220
241
|
```
|
|
221
242
|
|
|
222
243
|
Set the `builtin` version (the one sent to Apple store / Google play store ) as current version
|
|
223
244
|
|
|
224
|
-
| Param | Type
|
|
225
|
-
| ------------- |
|
|
226
|
-
| **`options`** | <code>{
|
|
245
|
+
| Param | Type |
|
|
246
|
+
| ------------- | -------------------------------------------- |
|
|
247
|
+
| **`options`** | <code>{ toLastSuccessful?: boolean; }</code> |
|
|
227
248
|
|
|
228
249
|
--------------------
|
|
229
250
|
|
|
@@ -231,12 +252,12 @@ Set the `builtin` version (the one sent to Apple store / Google play store ) as
|
|
|
231
252
|
### current()
|
|
232
253
|
|
|
233
254
|
```typescript
|
|
234
|
-
current() => Promise<{
|
|
255
|
+
current() => Promise<{ bundle: BundleInfo; native: string; }>
|
|
235
256
|
```
|
|
236
257
|
|
|
237
|
-
Get the current
|
|
258
|
+
Get the current bundle, if none are set it returns `builtin`, currentNative is the original bundle installed on the device
|
|
238
259
|
|
|
239
|
-
**Returns:** <code>Promise<{
|
|
260
|
+
**Returns:** <code>Promise<{ bundle: <a href="#bundleinfo">BundleInfo</a>; native: string; }></code>
|
|
240
261
|
|
|
241
262
|
--------------------
|
|
242
263
|
|
|
@@ -252,68 +273,57 @@ Reload the view
|
|
|
252
273
|
--------------------
|
|
253
274
|
|
|
254
275
|
|
|
255
|
-
###
|
|
276
|
+
### setDelay(...)
|
|
256
277
|
|
|
257
278
|
```typescript
|
|
258
|
-
|
|
279
|
+
setDelay(options: { delay: boolean; }) => Promise<void>
|
|
259
280
|
```
|
|
260
281
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
**Returns:** <code>Promise<{ versionName: string; }></code>
|
|
264
|
-
|
|
265
|
-
--------------------
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### notifyAppReady()
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
notifyAppReady() => Promise<void>
|
|
272
|
-
```
|
|
282
|
+
Set delay to skip updates in the next time the app goes into the background
|
|
273
283
|
|
|
274
|
-
|
|
284
|
+
| Param | Type |
|
|
285
|
+
| ------------- | -------------------------------- |
|
|
286
|
+
| **`options`** | <code>{ delay: boolean; }</code> |
|
|
275
287
|
|
|
276
288
|
--------------------
|
|
277
289
|
|
|
278
290
|
|
|
279
|
-
###
|
|
291
|
+
### addListener('download', ...)
|
|
280
292
|
|
|
281
293
|
```typescript
|
|
282
|
-
|
|
294
|
+
addListener(eventName: 'download', listenerFunc: DownloadChangeListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
283
295
|
```
|
|
284
296
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
--------------------
|
|
288
|
-
|
|
297
|
+
Listen for download event in the App, let you know when the download is started, loading and finished
|
|
289
298
|
|
|
290
|
-
|
|
299
|
+
| Param | Type |
|
|
300
|
+
| ------------------ | ------------------------------------------------------------------------- |
|
|
301
|
+
| **`eventName`** | <code>'download'</code> |
|
|
302
|
+
| **`listenerFunc`** | <code><a href="#downloadchangelistener">DownloadChangeListener</a></code> |
|
|
291
303
|
|
|
292
|
-
|
|
293
|
-
cancelDelay() => Promise<void>
|
|
294
|
-
```
|
|
304
|
+
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
295
305
|
|
|
296
|
-
|
|
306
|
+
**Since:** 2.0.11
|
|
297
307
|
|
|
298
308
|
--------------------
|
|
299
309
|
|
|
300
310
|
|
|
301
|
-
### addListener('
|
|
311
|
+
### addListener('downloadComplete', ...)
|
|
302
312
|
|
|
303
313
|
```typescript
|
|
304
|
-
addListener(eventName: '
|
|
314
|
+
addListener(eventName: 'downloadComplete', listenerFunc: DownloadCompleteListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
305
315
|
```
|
|
306
316
|
|
|
307
317
|
Listen for download event in the App, let you know when the download is started, loading and finished
|
|
308
318
|
|
|
309
|
-
| Param | Type
|
|
310
|
-
| ------------------ |
|
|
311
|
-
| **`eventName`** | <code>'
|
|
312
|
-
| **`listenerFunc`** | <code><a href="#
|
|
319
|
+
| Param | Type |
|
|
320
|
+
| ------------------ | ----------------------------------------------------------------------------- |
|
|
321
|
+
| **`eventName`** | <code>'downloadComplete'</code> |
|
|
322
|
+
| **`listenerFunc`** | <code><a href="#downloadcompletelistener">DownloadCompleteListener</a></code> |
|
|
313
323
|
|
|
314
324
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
315
325
|
|
|
316
|
-
**Since:**
|
|
326
|
+
**Since:** 4.0.0
|
|
317
327
|
|
|
318
328
|
--------------------
|
|
319
329
|
|
|
@@ -338,18 +348,18 @@ Listen for Major update event in the App, let you know when major update is bloc
|
|
|
338
348
|
--------------------
|
|
339
349
|
|
|
340
350
|
|
|
341
|
-
### addListener('
|
|
351
|
+
### addListener('updateFailed', ...)
|
|
342
352
|
|
|
343
353
|
```typescript
|
|
344
|
-
addListener(eventName: '
|
|
354
|
+
addListener(eventName: 'updateFailed', listenerFunc: UpdateFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
|
|
345
355
|
```
|
|
346
356
|
|
|
347
357
|
Listen for update event in the App, let you know when update is ready to install at next app start
|
|
348
358
|
|
|
349
|
-
| Param | Type
|
|
350
|
-
| ------------------ |
|
|
351
|
-
| **`eventName`** | <code>'
|
|
352
|
-
| **`listenerFunc`** | <code><a href="#
|
|
359
|
+
| Param | Type |
|
|
360
|
+
| ------------------ | --------------------------------------------------------------------- |
|
|
361
|
+
| **`eventName`** | <code>'updateFailed'</code> |
|
|
362
|
+
| **`listenerFunc`** | <code><a href="#updatefailedlistener">UpdateFailedListener</a></code> |
|
|
353
363
|
|
|
354
364
|
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>> & <a href="#pluginlistenerhandle">PluginListenerHandle</a></code>
|
|
355
365
|
|
|
@@ -358,6 +368,45 @@ Listen for update event in the App, let you know when update is ready to install
|
|
|
358
368
|
--------------------
|
|
359
369
|
|
|
360
370
|
|
|
371
|
+
### getId()
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
getId() => Promise<{ id: string; }>
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Get unique ID used to identify device (sent to auto update server)
|
|
378
|
+
|
|
379
|
+
**Returns:** <code>Promise<{ id: string; }></code>
|
|
380
|
+
|
|
381
|
+
--------------------
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
### getPluginVersion()
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
getPluginVersion() => Promise<{ version: string; }>
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Get the native Capacitor Updater plugin version (sent to auto update server)
|
|
391
|
+
|
|
392
|
+
**Returns:** <code>Promise<{ version: string; }></code>
|
|
393
|
+
|
|
394
|
+
--------------------
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
### isAutoUpdateEnabled()
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
isAutoUpdateEnabled() => Promise<{ enabled: boolean; }>
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Get the state of auto update config. This will return `false` in manual mode.
|
|
404
|
+
|
|
405
|
+
**Returns:** <code>Promise<{ enabled: boolean; }></code>
|
|
406
|
+
|
|
407
|
+
--------------------
|
|
408
|
+
|
|
409
|
+
|
|
361
410
|
### addListener(string, ...)
|
|
362
411
|
|
|
363
412
|
```typescript
|
|
@@ -386,6 +435,16 @@ removeAllListeners() => Promise<void>
|
|
|
386
435
|
### Interfaces
|
|
387
436
|
|
|
388
437
|
|
|
438
|
+
#### BundleInfo
|
|
439
|
+
|
|
440
|
+
| Prop | Type |
|
|
441
|
+
| ---------------- | ----------------------------------------------------- |
|
|
442
|
+
| **`id`** | <code>string</code> |
|
|
443
|
+
| **`version`** | <code>string</code> |
|
|
444
|
+
| **`downloaded`** | <code>string</code> |
|
|
445
|
+
| **`status`** | <code><a href="#bundlestatus">BundleStatus</a></code> |
|
|
446
|
+
|
|
447
|
+
|
|
389
448
|
#### PluginListenerHandle
|
|
390
449
|
|
|
391
450
|
| Prop | Type |
|
|
@@ -395,48 +454,66 @@ removeAllListeners() => Promise<void>
|
|
|
395
454
|
|
|
396
455
|
#### DownloadEvent
|
|
397
456
|
|
|
398
|
-
| Prop | Type
|
|
399
|
-
| ------------- |
|
|
400
|
-
| **`percent`** | <code>number</code>
|
|
457
|
+
| Prop | Type | Description | Since |
|
|
458
|
+
| ------------- | ------------------------------------------------- | ---------------------------------------------- | ----- |
|
|
459
|
+
| **`percent`** | <code>number</code> | Current status of download, between 0 and 100. | 4.0.0 |
|
|
460
|
+
| **`bundle`** | <code><a href="#bundleinfo">BundleInfo</a></code> | | |
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
#### DownloadCompleteEvent
|
|
464
|
+
|
|
465
|
+
| Prop | Type | Description | Since |
|
|
466
|
+
| ------------ | ------------------------------------------------- | ------------------------------------ | ----- |
|
|
467
|
+
| **`bundle`** | <code><a href="#bundleinfo">BundleInfo</a></code> | Emit when a new update is available. | 4.0.0 |
|
|
401
468
|
|
|
402
469
|
|
|
403
470
|
#### MajorAvailableEvent
|
|
404
471
|
|
|
405
472
|
| Prop | Type | Description | Since |
|
|
406
473
|
| ------------- | ------------------- | ------------------------------------------- | ----- |
|
|
407
|
-
| **`version`** | <code>string</code> | Emit when a new major version is available. |
|
|
474
|
+
| **`version`** | <code>string</code> | Emit when a new major version is available. | 4.0.0 |
|
|
408
475
|
|
|
409
476
|
|
|
410
|
-
####
|
|
477
|
+
#### UpdateFailedEvent
|
|
411
478
|
|
|
412
|
-
| Prop
|
|
413
|
-
|
|
|
414
|
-
| **`
|
|
479
|
+
| Prop | Type | Description | Since |
|
|
480
|
+
| ------------ | ------------------------------------------------- | ------------------------------------- | ----- |
|
|
481
|
+
| **`bundle`** | <code><a href="#bundleinfo">BundleInfo</a></code> | Emit when a update failed to install. | 4.0.0 |
|
|
415
482
|
|
|
416
483
|
|
|
417
484
|
### Type Aliases
|
|
418
485
|
|
|
419
486
|
|
|
487
|
+
#### BundleStatus
|
|
488
|
+
|
|
489
|
+
<code>'success' | 'error' | 'pending' | 'downloading'</code>
|
|
490
|
+
|
|
491
|
+
|
|
420
492
|
#### DownloadChangeListener
|
|
421
493
|
|
|
422
494
|
<code>(state: <a href="#downloadevent">DownloadEvent</a>): void</code>
|
|
423
495
|
|
|
424
496
|
|
|
497
|
+
#### DownloadCompleteListener
|
|
498
|
+
|
|
499
|
+
<code>(state: <a href="#downloadcompleteevent">DownloadCompleteEvent</a>): void</code>
|
|
500
|
+
|
|
501
|
+
|
|
425
502
|
#### MajorAvailableListener
|
|
426
503
|
|
|
427
504
|
<code>(state: <a href="#majoravailableevent">MajorAvailableEvent</a>): void</code>
|
|
428
505
|
|
|
429
506
|
|
|
430
|
-
####
|
|
507
|
+
#### UpdateFailedListener
|
|
431
508
|
|
|
432
|
-
<code>(state: <a href="#
|
|
509
|
+
<code>(state: <a href="#updatefailedevent">UpdateFailedEvent</a>): void</code>
|
|
433
510
|
|
|
434
511
|
</docgen-api>
|
|
435
512
|
|
|
436
513
|
### Listen to download events
|
|
437
514
|
|
|
438
515
|
```javascript
|
|
439
|
-
import { CapacitorUpdater } from 'capacitor-updater';
|
|
516
|
+
import { CapacitorUpdater } from '@capgo/capacitor-updater';
|
|
440
517
|
|
|
441
518
|
CapacitorUpdater.addListener('download', (info: any) => {
|
|
442
519
|
console.log('download was fired', info.percent);
|