native-update 1.0.3 → 1.0.5
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/docs/APP_REVIEW_GUIDE.md +2 -2
- package/docs/BUNDLE_SIGNING.md +10 -4
- package/docs/LIVE_UPDATES_GUIDE.md +152 -127
- package/docs/MIGRATION.md +2 -2
- package/docs/NATIVE_UPDATES_GUIDE.md +17 -16
- package/docs/QUICK_START.md +64 -75
- package/docs/README.md +4 -5
- package/docs/api/app-review-api.md +1 -21
- package/docs/api/app-update-api.md +18 -110
- package/docs/api/events-api.md +83 -334
- package/docs/api/live-update-api.md +63 -86
- package/docs/examples/advanced-scenarios.md +72 -88
- package/docs/examples/basic-usage.md +41 -38
- package/docs/features/app-reviews.md +1 -1
- package/docs/features/app-updates.md +1 -1
- package/docs/features/live-updates.md +23 -14
- package/docs/getting-started/configuration.md +1 -1
- package/docs/getting-started/installation.md +2 -2
- package/docs/getting-started/quick-start.md +3 -3
- package/docs/guides/migration-from-codepush.md +10 -11
- package/docs/guides/security-best-practices.md +3 -3
- package/docs/guides/testing-guide.md +27 -28
- package/package.json +1 -1
|
@@ -10,13 +10,10 @@ Minimize download sizes by only downloading changed files:
|
|
|
10
10
|
import { NativeUpdate } from 'native-update';
|
|
11
11
|
|
|
12
12
|
async function checkForDeltaUpdate() {
|
|
13
|
-
const currentManifest = await NativeUpdate.
|
|
13
|
+
const currentManifest = await NativeUpdate.current();
|
|
14
14
|
|
|
15
|
-
const result = await NativeUpdate.
|
|
16
|
-
|
|
17
|
-
currentVersion: currentManifest.version,
|
|
18
|
-
currentChecksum: currentManifest.checksum,
|
|
19
|
-
supportsDelta: true
|
|
15
|
+
const result = await NativeUpdate.sync({
|
|
16
|
+
installMode: 'ON_NEXT_RESTART'
|
|
20
17
|
});
|
|
21
18
|
|
|
22
19
|
if (result.updateAvailable && result.deltaAvailable) {
|
|
@@ -26,15 +23,18 @@ async function checkForDeltaUpdate() {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
async function downloadDeltaUpdate(deltaUrl: string) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
// Download requires url, version, and checksum parameters
|
|
27
|
+
const download = await NativeUpdate.download({
|
|
28
|
+
url: result.deltaUrl,
|
|
29
|
+
version: result.version,
|
|
30
|
+
checksum: result.checksum
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
//
|
|
35
|
-
await NativeUpdate.
|
|
33
|
+
// Set the bundle as active
|
|
34
|
+
await NativeUpdate.set({
|
|
36
35
|
bundleId: download.bundleId,
|
|
37
|
-
|
|
36
|
+
version: download.version,
|
|
37
|
+
checksum: download.checksum
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
```
|
|
@@ -63,9 +63,7 @@ async function switchToBetaChannel() {
|
|
|
63
63
|
await setupUpdateChannel(UpdateChannel.BETA);
|
|
64
64
|
|
|
65
65
|
// Check for updates in the new channel
|
|
66
|
-
const result = await NativeUpdate.
|
|
67
|
-
currentVersion: await getCurrentVersion()
|
|
68
|
-
});
|
|
66
|
+
const result = await NativeUpdate.sync();
|
|
69
67
|
|
|
70
68
|
if (result.updateAvailable) {
|
|
71
69
|
console.log(`Beta update ${result.version} available`);
|
|
@@ -82,13 +80,8 @@ async function checkStagedUpdate() {
|
|
|
82
80
|
const deviceId = await getDeviceId();
|
|
83
81
|
const rolloutPercentage = hashDeviceId(deviceId) % 100;
|
|
84
82
|
|
|
85
|
-
const result = await NativeUpdate.
|
|
86
|
-
|
|
87
|
-
currentVersion: '1.0.0',
|
|
88
|
-
metadata: {
|
|
89
|
-
deviceId,
|
|
90
|
-
rolloutGroup: rolloutPercentage
|
|
91
|
-
}
|
|
83
|
+
const result = await NativeUpdate.sync({
|
|
84
|
+
installMode: 'ON_NEXT_RESTART'
|
|
92
85
|
});
|
|
93
86
|
|
|
94
87
|
if (result.updateAvailable && result.rolloutPercentage >= rolloutPercentage) {
|
|
@@ -110,21 +103,22 @@ async function setupBackgroundUpdates() {
|
|
|
110
103
|
autoInstallMode: 'on-restart'
|
|
111
104
|
});
|
|
112
105
|
|
|
113
|
-
//
|
|
114
|
-
await NativeUpdate.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
requiresCharging: false
|
|
106
|
+
// Configure automatic update checks
|
|
107
|
+
await NativeUpdate.configure({
|
|
108
|
+
checkInterval: 14400, // 4 hours in seconds
|
|
109
|
+
autoCheck: true
|
|
118
110
|
});
|
|
119
111
|
}
|
|
120
112
|
|
|
121
113
|
// Handle background update events
|
|
122
|
-
NativeUpdate.addListener('
|
|
114
|
+
NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
|
|
123
115
|
// Notify user that update is ready
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
if (event.updateAvailable) {
|
|
117
|
+
showUpdateNotification({
|
|
118
|
+
version: event.version,
|
|
119
|
+
type: event.type
|
|
120
|
+
});
|
|
121
|
+
}
|
|
128
122
|
});
|
|
129
123
|
```
|
|
130
124
|
|
|
@@ -134,14 +128,15 @@ Implement automatic rollback on update failures:
|
|
|
134
128
|
|
|
135
129
|
```typescript
|
|
136
130
|
async function safeUpdate() {
|
|
137
|
-
//
|
|
138
|
-
const backup = await NativeUpdate.
|
|
131
|
+
// Get current version info before update
|
|
132
|
+
const backup = await NativeUpdate.current();
|
|
139
133
|
|
|
140
134
|
try {
|
|
141
135
|
// Attempt update
|
|
142
|
-
await NativeUpdate.
|
|
136
|
+
await NativeUpdate.set({
|
|
143
137
|
bundleId: 'new-update-id',
|
|
144
|
-
|
|
138
|
+
version: 'new-version',
|
|
139
|
+
checksum: 'bundle-checksum'
|
|
145
140
|
});
|
|
146
141
|
|
|
147
142
|
// Verify update success
|
|
@@ -150,15 +145,13 @@ async function safeUpdate() {
|
|
|
150
145
|
throw new Error('Health check failed');
|
|
151
146
|
}
|
|
152
147
|
|
|
153
|
-
//
|
|
154
|
-
await NativeUpdate.
|
|
148
|
+
// Notify app is ready with new bundle
|
|
149
|
+
await NativeUpdate.notifyAppReady();
|
|
155
150
|
} catch (error) {
|
|
156
151
|
console.error('Update failed, rolling back:', error);
|
|
157
152
|
|
|
158
153
|
// Automatic rollback
|
|
159
|
-
await NativeUpdate.
|
|
160
|
-
backupId: backup.id
|
|
161
|
-
});
|
|
154
|
+
await NativeUpdate.reset();
|
|
162
155
|
|
|
163
156
|
// Report failure to analytics
|
|
164
157
|
reportUpdateFailure(error);
|
|
@@ -201,18 +194,17 @@ async function setupABTest(config: ABTestConfig) {
|
|
|
201
194
|
? config.variants.treatment
|
|
202
195
|
: config.variants.control;
|
|
203
196
|
|
|
204
|
-
const download = await NativeUpdate.
|
|
197
|
+
const download = await NativeUpdate.download({
|
|
205
198
|
url: bundleUrl,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
variant
|
|
209
|
-
}
|
|
199
|
+
version: variant,
|
|
200
|
+
checksum: 'bundle-checksum' // This should come from server
|
|
210
201
|
});
|
|
211
202
|
|
|
212
|
-
//
|
|
213
|
-
await NativeUpdate.
|
|
203
|
+
// Set the bundle as active
|
|
204
|
+
await NativeUpdate.set({
|
|
214
205
|
bundleId: download.bundleId,
|
|
215
|
-
|
|
206
|
+
version: download.version,
|
|
207
|
+
checksum: download.checksum
|
|
216
208
|
});
|
|
217
209
|
}
|
|
218
210
|
```
|
|
@@ -227,10 +219,7 @@ class UpdateManager {
|
|
|
227
219
|
|
|
228
220
|
async checkAndPromptUpdate() {
|
|
229
221
|
// Check for update
|
|
230
|
-
const result = await NativeUpdate.
|
|
231
|
-
updateUrl: 'https://your-update-server.com/api/check',
|
|
232
|
-
currentVersion: await this.getCurrentVersion()
|
|
233
|
-
});
|
|
222
|
+
const result = await NativeUpdate.sync();
|
|
234
223
|
|
|
235
224
|
if (!result.updateAvailable) return;
|
|
236
225
|
|
|
@@ -265,15 +254,20 @@ class UpdateManager {
|
|
|
265
254
|
);
|
|
266
255
|
|
|
267
256
|
try {
|
|
268
|
-
|
|
269
|
-
|
|
257
|
+
// Download requires url, version, and checksum
|
|
258
|
+
const download = await NativeUpdate.download({
|
|
259
|
+
url: updateInfo.url,
|
|
260
|
+
version: updateInfo.version,
|
|
261
|
+
checksum: updateInfo.checksum
|
|
270
262
|
});
|
|
271
263
|
|
|
272
264
|
this.updateState = { status: 'installing' };
|
|
273
265
|
this.updateUI();
|
|
274
266
|
|
|
275
|
-
await NativeUpdate.
|
|
276
|
-
bundleId: download.bundleId
|
|
267
|
+
await NativeUpdate.set({
|
|
268
|
+
bundleId: download.bundleId,
|
|
269
|
+
version: download.version,
|
|
270
|
+
checksum: download.checksum
|
|
277
271
|
});
|
|
278
272
|
|
|
279
273
|
this.updateState = { status: 'ready' };
|
|
@@ -300,18 +294,7 @@ async function secureUpdateCheck() {
|
|
|
300
294
|
version: getCurrentVersion()
|
|
301
295
|
});
|
|
302
296
|
|
|
303
|
-
const result = await NativeUpdate.
|
|
304
|
-
updateUrl: 'https://your-update-server.com/api/check',
|
|
305
|
-
currentVersion: getCurrentVersion(),
|
|
306
|
-
headers: {
|
|
307
|
-
'X-Timestamp': timestamp.toString(),
|
|
308
|
-
'X-Nonce': nonce,
|
|
309
|
-
'X-Signature': signature
|
|
310
|
-
},
|
|
311
|
-
certificatePins: [
|
|
312
|
-
'sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
|
|
313
|
-
]
|
|
314
|
-
});
|
|
297
|
+
const result = await NativeUpdate.sync();
|
|
315
298
|
|
|
316
299
|
// Verify response signature
|
|
317
300
|
if (!await verifyUpdateSignature(result)) {
|
|
@@ -322,20 +305,20 @@ async function secureUpdateCheck() {
|
|
|
322
305
|
}
|
|
323
306
|
|
|
324
307
|
async function downloadWithIntegrityCheck(url: string, expectedHash: string) {
|
|
325
|
-
const download = await NativeUpdate.
|
|
326
|
-
url,
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
algorithm: 'sha256'
|
|
308
|
+
const download = await NativeUpdate.download({
|
|
309
|
+
url: url,
|
|
310
|
+
version: 'secure-version',
|
|
311
|
+
checksum: expectedHash
|
|
330
312
|
});
|
|
331
313
|
|
|
332
314
|
// Additional verification
|
|
333
|
-
const verified = await NativeUpdate.
|
|
334
|
-
|
|
335
|
-
|
|
315
|
+
const verified = await NativeUpdate.LiveUpdate.validateUpdate({
|
|
316
|
+
bundlePath: download.path,
|
|
317
|
+
checksum: download.checksum,
|
|
318
|
+
signature: 'bundle-signature'
|
|
336
319
|
});
|
|
337
320
|
|
|
338
|
-
if (!verified.
|
|
321
|
+
if (!verified.isValid) {
|
|
339
322
|
throw new Error('Bundle verification failed');
|
|
340
323
|
}
|
|
341
324
|
|
|
@@ -362,10 +345,7 @@ class UpdateMetrics {
|
|
|
362
345
|
|
|
363
346
|
try {
|
|
364
347
|
// Check phase
|
|
365
|
-
const result = await NativeUpdate.
|
|
366
|
-
updateUrl: 'https://your-update-server.com/api/check',
|
|
367
|
-
currentVersion: getCurrentVersion()
|
|
368
|
-
});
|
|
348
|
+
const result = await NativeUpdate.sync();
|
|
369
349
|
|
|
370
350
|
if (!result.updateAvailable) {
|
|
371
351
|
metrics.checkCompleted = Date.now();
|
|
@@ -375,16 +355,20 @@ class UpdateMetrics {
|
|
|
375
355
|
|
|
376
356
|
// Download phase
|
|
377
357
|
metrics.downloadStarted = Date.now();
|
|
378
|
-
const download = await NativeUpdate.
|
|
379
|
-
url: result.
|
|
358
|
+
const download = await NativeUpdate.download({
|
|
359
|
+
url: result.url,
|
|
360
|
+
version: result.version,
|
|
361
|
+
checksum: result.checksum
|
|
380
362
|
});
|
|
381
363
|
metrics.downloadCompleted = Date.now();
|
|
382
364
|
metrics.downloadSize = download.size;
|
|
383
365
|
|
|
384
366
|
// Install phase
|
|
385
367
|
metrics.installStarted = Date.now();
|
|
386
|
-
await NativeUpdate.
|
|
387
|
-
bundleId: download.bundleId
|
|
368
|
+
await NativeUpdate.set({
|
|
369
|
+
bundleId: download.bundleId,
|
|
370
|
+
version: download.version,
|
|
371
|
+
checksum: download.checksum
|
|
388
372
|
});
|
|
389
373
|
metrics.installCompleted = Date.now();
|
|
390
374
|
|
|
@@ -405,6 +389,6 @@ class UpdateMetrics {
|
|
|
405
389
|
|
|
406
390
|
## Next Steps
|
|
407
391
|
|
|
408
|
-
- Review [
|
|
409
|
-
- See the [API Reference](../api/
|
|
392
|
+
- Review [Basic Usage](./basic-usage.md) for framework-specific implementations
|
|
393
|
+
- See the [API Reference](../api/live-update-api.md) for detailed method documentation
|
|
410
394
|
- Check [Basic Usage](./basic-usage.md) for simpler examples
|
|
@@ -17,39 +17,37 @@ import { NativeUpdate } from 'native-update';
|
|
|
17
17
|
// Check for updates on app startup
|
|
18
18
|
async function checkForUpdates() {
|
|
19
19
|
try {
|
|
20
|
-
const result = await NativeUpdate.
|
|
21
|
-
updateUrl: 'https://your-update-server.com/api/check'
|
|
22
|
-
currentVersion: '1.0.0'
|
|
20
|
+
const result = await NativeUpdate.sync({
|
|
21
|
+
updateUrl: 'https://your-update-server.com/api/check'
|
|
23
22
|
});
|
|
24
23
|
|
|
25
|
-
if (result.
|
|
26
|
-
console.log(`Update available: ${result.version}`);
|
|
27
|
-
//
|
|
28
|
-
|
|
24
|
+
if (result.status === 'UPDATE_AVAILABLE') {
|
|
25
|
+
console.log(`Update available: ${result.bundle?.version}`);
|
|
26
|
+
// Update will be downloaded and installed automatically
|
|
27
|
+
} else if (result.status === 'UPDATE_INSTALLED') {
|
|
28
|
+
// Reload the app to apply the update
|
|
29
|
+
await NativeUpdate.reload();
|
|
29
30
|
}
|
|
30
31
|
} catch (error) {
|
|
31
32
|
console.error('Update check failed:', error);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
async function downloadAndInstall(
|
|
36
|
-
// Download
|
|
37
|
-
const download = await NativeUpdate.
|
|
38
|
-
|
|
36
|
+
async function downloadAndInstall(version: string) {
|
|
37
|
+
// Download a specific version
|
|
38
|
+
const download = await NativeUpdate.download({
|
|
39
|
+
version: version
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
//
|
|
42
|
-
NativeUpdate.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Install the update
|
|
47
|
-
await NativeUpdate.installUpdate({
|
|
48
|
-
bundleId: download.bundleId
|
|
42
|
+
// Set the downloaded bundle as active
|
|
43
|
+
await NativeUpdate.set({
|
|
44
|
+
bundleId: download.bundleId,
|
|
45
|
+
version: download.version,
|
|
46
|
+
checksum: download.checksum
|
|
49
47
|
});
|
|
50
48
|
|
|
51
49
|
// Reload the app with new bundle
|
|
52
|
-
await NativeUpdate.
|
|
50
|
+
await NativeUpdate.reload();
|
|
53
51
|
}
|
|
54
52
|
```
|
|
55
53
|
|
|
@@ -58,7 +56,7 @@ async function downloadAndInstall(downloadUrl: string) {
|
|
|
58
56
|
```typescript
|
|
59
57
|
// Check if a native app update is available
|
|
60
58
|
async function checkAppStoreUpdate() {
|
|
61
|
-
const result = await NativeUpdate.
|
|
59
|
+
const result = await NativeUpdate.getAppUpdateInfo();
|
|
62
60
|
|
|
63
61
|
if (result.updateAvailable) {
|
|
64
62
|
// Show update prompt to user
|
|
@@ -147,12 +145,11 @@ await NativeUpdate.configure({
|
|
|
147
145
|
// Comprehensive error handling
|
|
148
146
|
async function safeUpdateCheck() {
|
|
149
147
|
try {
|
|
150
|
-
const result = await NativeUpdate.
|
|
151
|
-
updateUrl: 'https://your-update-server.com/api/check'
|
|
152
|
-
currentVersion: '1.0.0'
|
|
148
|
+
const result = await NativeUpdate.sync({
|
|
149
|
+
updateUrl: 'https://your-update-server.com/api/check'
|
|
153
150
|
});
|
|
154
151
|
|
|
155
|
-
if (result.
|
|
152
|
+
if (result.status === 'UPDATE_AVAILABLE' || result.status === 'UPDATE_INSTALLED') {
|
|
156
153
|
await handleUpdate(result);
|
|
157
154
|
}
|
|
158
155
|
} catch (error) {
|
|
@@ -172,21 +169,26 @@ async function safeUpdateCheck() {
|
|
|
172
169
|
```typescript
|
|
173
170
|
// Set up event listeners
|
|
174
171
|
function setupUpdateListeners() {
|
|
175
|
-
//
|
|
176
|
-
NativeUpdate.addListener('
|
|
177
|
-
|
|
172
|
+
// Update state changes
|
|
173
|
+
NativeUpdate.addListener('updateStateChanged', (event) => {
|
|
174
|
+
console.log('Update state:', event.status);
|
|
175
|
+
if (event.status === 'READY') {
|
|
176
|
+
// Update has been applied successfully
|
|
177
|
+
console.log('Update ready to use');
|
|
178
|
+
}
|
|
178
179
|
});
|
|
179
180
|
|
|
180
|
-
//
|
|
181
|
-
NativeUpdate.addListener('
|
|
182
|
-
console.log(`
|
|
181
|
+
// Download progress
|
|
182
|
+
NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
183
|
+
console.log(`Download progress: ${progress.percent}%`);
|
|
184
|
+
console.log(`Speed: ${progress.bytesPerSecond} bytes/s`);
|
|
183
185
|
});
|
|
184
186
|
|
|
185
|
-
//
|
|
186
|
-
NativeUpdate.addListener('
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
// Background update notifications
|
|
188
|
+
NativeUpdate.addListener('backgroundUpdateNotification', (event) => {
|
|
189
|
+
if (event.updateAvailable) {
|
|
190
|
+
console.log(`Background update available: ${event.version}`);
|
|
191
|
+
}
|
|
190
192
|
});
|
|
191
193
|
}
|
|
192
194
|
|
|
@@ -199,5 +201,6 @@ function cleanup() {
|
|
|
199
201
|
## Next Steps
|
|
200
202
|
|
|
201
203
|
- See [Advanced Scenarios](./advanced-scenarios.md) for more complex use cases
|
|
202
|
-
-
|
|
203
|
-
- Read the [API Reference](../api/
|
|
204
|
+
- Read the [Live Update API Reference](../api/live-update-api.md) for complete live update methods
|
|
205
|
+
- Read the [App Update API Reference](../api/app-update-api.md) for native update methods
|
|
206
|
+
- Read the [App Review API Reference](../api/app-review-api.md) for review request methods
|
|
@@ -966,7 +966,7 @@ async function monitorReviewSuccess() {
|
|
|
966
966
|
## Next Steps
|
|
967
967
|
|
|
968
968
|
- Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
969
|
-
-
|
|
969
|
+
- Review the [API Reference](../api/app-review-api.md)
|
|
970
970
|
- Configure [Live Updates](./live-updates.md)
|
|
971
971
|
- Review [API Reference](../api/app-review-api.md)
|
|
972
972
|
|
|
@@ -777,7 +777,7 @@ async function trackUpdateMetrics(event: string, data: any) {
|
|
|
777
777
|
|
|
778
778
|
- Configure [App Reviews](./app-reviews.md) for user feedback
|
|
779
779
|
- Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
780
|
-
-
|
|
780
|
+
- Review [Testing Guide](../guides/testing-guide.md)
|
|
781
781
|
- Review [API Reference](../api/app-update-api.md)
|
|
782
782
|
|
|
783
783
|
---
|
|
@@ -379,9 +379,10 @@ async function getFeatureFlags() {
|
|
|
379
379
|
2. **Implement delta updates** (coming soon):
|
|
380
380
|
```typescript
|
|
381
381
|
// Future API
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
// Note: Delta updates are handled automatically by the sync() method
|
|
383
|
+
// when configured on the server. Direct delta download is not available
|
|
384
|
+
const bundle = await NativeUpdate.LiveUpdate.download({
|
|
385
|
+
version: latest.version,
|
|
385
386
|
});
|
|
386
387
|
```
|
|
387
388
|
|
|
@@ -409,15 +410,23 @@ async function getFeatureFlags() {
|
|
|
409
410
|
### Storage Management
|
|
410
411
|
|
|
411
412
|
```typescript
|
|
412
|
-
// Monitor
|
|
413
|
-
const
|
|
414
|
-
console.log(`
|
|
415
|
-
|
|
416
|
-
// Clean up
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
413
|
+
// Monitor bundle count and clean up old versions
|
|
414
|
+
const bundles = await NativeUpdate.LiveUpdate.list();
|
|
415
|
+
console.log(`Total bundles: ${bundles.length}`);
|
|
416
|
+
|
|
417
|
+
// Clean up old bundles (keep only recent 5)
|
|
418
|
+
if (bundles.length > 5) {
|
|
419
|
+
// Sort by downloadTime and keep the 5 most recent
|
|
420
|
+
const sortedBundles = bundles.sort((a, b) =>
|
|
421
|
+
new Date(b.downloadTime).getTime() - new Date(a.downloadTime).getTime()
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
const toDelete = sortedBundles.slice(5);
|
|
425
|
+
for (const bundle of toDelete) {
|
|
426
|
+
await NativeUpdate.LiveUpdate.delete({
|
|
427
|
+
bundleId: bundle.bundleId,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
421
430
|
}
|
|
422
431
|
```
|
|
423
432
|
|
|
@@ -526,7 +535,7 @@ const devConfig = {
|
|
|
526
535
|
};
|
|
527
536
|
|
|
528
537
|
// Force update check
|
|
529
|
-
await NativeUpdate.LiveUpdate.sync(
|
|
538
|
+
await NativeUpdate.LiveUpdate.sync();
|
|
530
539
|
|
|
531
540
|
// Simulate different scenarios
|
|
532
541
|
await testUpdateScenarios();
|
|
@@ -623,7 +632,7 @@ async function loadFeature(featureName: string) {
|
|
|
623
632
|
|
|
624
633
|
## Next Steps
|
|
625
634
|
|
|
626
|
-
- Set up your
|
|
635
|
+
- Set up your update server (see backend-template folder)
|
|
627
636
|
- Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
628
637
|
- Configure [App Updates](./app-updates.md) for native changes
|
|
629
638
|
- Explore [API Reference](../api/live-update-api.md)
|
|
@@ -460,7 +460,7 @@ try {
|
|
|
460
460
|
## Next Steps
|
|
461
461
|
|
|
462
462
|
- Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
463
|
-
- Set up your
|
|
463
|
+
- Set up your update server (see backend-template folder)
|
|
464
464
|
- Explore [Advanced Features](../features/live-updates.md)
|
|
465
465
|
|
|
466
466
|
---
|
|
@@ -194,13 +194,13 @@ After successful installation:
|
|
|
194
194
|
1. Read the [Quick Start Guide](./quick-start.md) for basic usage
|
|
195
195
|
2. Configure the plugin with your [update server settings](./configuration.md)
|
|
196
196
|
3. Implement [security best practices](../guides/security-best-practices.md)
|
|
197
|
-
4. Set up your
|
|
197
|
+
4. Set up your update server (see backend-template folder)
|
|
198
198
|
|
|
199
199
|
## Support
|
|
200
200
|
|
|
201
201
|
If you encounter any issues during installation:
|
|
202
202
|
|
|
203
|
-
- Check our [
|
|
203
|
+
- Check our [Testing Guide](../guides/testing-guide.md)
|
|
204
204
|
- Search existing [GitHub Issues](https://github.com/aoneahsan/native-update/issues)
|
|
205
205
|
- Create a new issue with detailed information about your setup
|
|
206
206
|
|
|
@@ -53,7 +53,7 @@ initializeUpdates();
|
|
|
53
53
|
// Sync with server and apply updates if available
|
|
54
54
|
async function syncUpdates() {
|
|
55
55
|
try {
|
|
56
|
-
const result = await NativeUpdate.
|
|
56
|
+
const result = await NativeUpdate.sync();
|
|
57
57
|
|
|
58
58
|
if (result.status === 'UPDATE_INSTALLED') {
|
|
59
59
|
console.log('Update installed:', result.bundle.version);
|
|
@@ -259,7 +259,7 @@ class UpdateManager {
|
|
|
259
259
|
|
|
260
260
|
async checkForUpdates() {
|
|
261
261
|
try {
|
|
262
|
-
const result = await NativeUpdate.
|
|
262
|
+
const result = await NativeUpdate.sync();
|
|
263
263
|
|
|
264
264
|
if (result.status === 'UPDATE_INSTALLED') {
|
|
265
265
|
// Notify user about update
|
|
@@ -349,7 +349,7 @@ async function safeUpdateCheck() {
|
|
|
349
349
|
|
|
350
350
|
Now that you have the basics working:
|
|
351
351
|
|
|
352
|
-
1. Set up your
|
|
352
|
+
1. Set up your update server (see backend-template folder)
|
|
353
353
|
2. Implement [Security Best Practices](../guides/security-best-practices.md)
|
|
354
354
|
3. Configure [Advanced Options](./configuration.md)
|
|
355
355
|
4. Explore [API Reference](../api/live-update-api.md) for all available methods
|
|
@@ -73,11 +73,10 @@ codePush.sync({
|
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
// New (Capacitor Native Update)
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
76
|
+
const result = await NativeUpdate.sync({
|
|
77
|
+
installMode: 'IMMEDIATE'
|
|
78
|
+
});
|
|
79
|
+
// Sync handles check, download, and apply automatically
|
|
81
80
|
```
|
|
82
81
|
|
|
83
82
|
### 5. Bundle Creation
|
|
@@ -98,11 +97,11 @@ node tools/bundle-signer.js sign bundle.zip private-key.pem
|
|
|
98
97
|
|
|
99
98
|
| CodePush Feature | Capacitor Native Update |
|
|
100
99
|
|-----------------|------------------------|
|
|
101
|
-
| sync() |
|
|
102
|
-
| getUpdateMetadata() |
|
|
103
|
-
| notifyAppReady() |
|
|
104
|
-
| restartApp() |
|
|
105
|
-
| clearUpdates() |
|
|
100
|
+
| sync() | sync() |
|
|
101
|
+
| getUpdateMetadata() | current() |
|
|
102
|
+
| notifyAppReady() | notifyAppReady() |
|
|
103
|
+
| restartApp() | reload() |
|
|
104
|
+
| clearUpdates() | reset() |
|
|
106
105
|
|
|
107
106
|
## Migration Checklist
|
|
108
107
|
|
|
@@ -137,6 +136,6 @@ node tools/bundle-signer.js sign bundle.zip private-key.pem
|
|
|
137
136
|
|
|
138
137
|
## Need Help?
|
|
139
138
|
|
|
140
|
-
- See [
|
|
139
|
+
- See [Testing Guide](../guides/testing-guide.md)
|
|
141
140
|
- Check [Server Requirements](../server-requirements.md)
|
|
142
141
|
- Review [Security Best Practices](./security-best-practices.md)
|
|
@@ -1048,9 +1048,9 @@ const productionSecurityConfig = {
|
|
|
1048
1048
|
## Next Steps
|
|
1049
1049
|
|
|
1050
1050
|
- Review [Production Readiness](../production-readiness.md) checklist
|
|
1051
|
-
- Implement
|
|
1052
|
-
- Set up
|
|
1053
|
-
- Configure
|
|
1051
|
+
- Implement proper monitoring and analytics
|
|
1052
|
+
- Set up incident response procedures
|
|
1053
|
+
- Configure update server security (see backend-template folder)
|
|
1054
1054
|
|
|
1055
1055
|
---
|
|
1056
1056
|
|