native-update 1.0.0 → 1.0.1
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/{CapacitorNativeUpdate.podspec → NativeUpdate.podspec} +1 -1
- package/Readme.md +16 -16
- package/android/src/main/java/com/aoneahsan/nativeupdate/{CapacitorNativeUpdatePlugin.kt → NativeUpdatePlugin.kt} +2 -2
- package/dist/esm/core/errors.d.ts +6 -6
- package/dist/esm/core/errors.js +8 -8
- package/dist/esm/core/errors.js.map +1 -1
- package/dist/esm/core/logger.js +1 -1
- package/dist/esm/core/logger.js.map +1 -1
- package/dist/esm/core/plugin-manager.js +3 -3
- package/dist/esm/core/plugin-manager.js.map +1 -1
- package/dist/esm/definitions.d.ts +12 -14
- package/dist/esm/definitions.js +1 -0
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugin.d.ts +3 -3
- package/dist/esm/plugin.js +13 -13
- package/dist/esm/plugin.js.map +1 -1
- package/dist/esm/web.d.ts +0 -1
- package/dist/esm/web.js +3 -3
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.esm.js +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/docs/APP_REVIEW_GUIDE.md +12 -12
- package/docs/BUNDLE_SIGNING.md +4 -4
- package/docs/LIVE_UPDATES_GUIDE.md +48 -48
- package/docs/MIGRATION.md +10 -10
- package/docs/NATIVE_UPDATES_GUIDE.md +25 -25
- package/docs/QUICK_START.md +34 -34
- package/docs/README.md +5 -5
- package/docs/api/app-review-api.md +15 -15
- package/docs/api/app-update-api.md +18 -18
- package/docs/api/events-api.md +23 -23
- package/docs/api/live-update-api.md +20 -20
- package/docs/background-updates.md +18 -18
- package/docs/examples/advanced-scenarios.md +27 -27
- package/docs/examples/basic-usage.md +17 -17
- package/docs/features/app-reviews.md +13 -13
- package/docs/features/app-updates.md +21 -21
- package/docs/features/live-updates.md +32 -32
- package/docs/getting-started/configuration.md +8 -8
- package/docs/getting-started/installation.md +4 -4
- package/docs/getting-started/quick-start.md +28 -28
- package/docs/guides/deployment-guide.md +2 -2
- package/docs/guides/migration-from-codepush.md +5 -5
- package/docs/guides/testing-guide.md +17 -17
- package/docs/security/certificate-pinning.md +2 -2
- package/ios/Plugin/{CapacitorNativeUpdatePlugin.m → NativeUpdatePlugin.m} +1 -1
- package/package.json +2 -2
- /package/ios/Plugin/{CapacitorNativeUpdatePlugin.swift → NativeUpdatePlugin.swift} +0 -0
|
@@ -7,12 +7,12 @@ This guide covers complex use cases and advanced patterns for the Capacitor Nati
|
|
|
7
7
|
Minimize download sizes by only downloading changed files:
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
import {
|
|
10
|
+
import { NativeUpdate } from 'native-update';
|
|
11
11
|
|
|
12
12
|
async function checkForDeltaUpdate() {
|
|
13
|
-
const currentManifest = await
|
|
13
|
+
const currentManifest = await NativeUpdate.getCurrentManifest();
|
|
14
14
|
|
|
15
|
-
const result = await
|
|
15
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
16
16
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
17
17
|
currentVersion: currentManifest.version,
|
|
18
18
|
currentChecksum: currentManifest.checksum,
|
|
@@ -26,13 +26,13 @@ async function checkForDeltaUpdate() {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async function downloadDeltaUpdate(deltaUrl: string) {
|
|
29
|
-
const download = await
|
|
29
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
30
30
|
url: deltaUrl,
|
|
31
31
|
isDelta: true
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// Apply delta patch
|
|
35
|
-
await
|
|
35
|
+
await NativeUpdate.applyDelta({
|
|
36
36
|
bundleId: download.bundleId,
|
|
37
37
|
baseVersion: getCurrentVersion()
|
|
38
38
|
});
|
|
@@ -52,7 +52,7 @@ enum UpdateChannel {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async function setupUpdateChannel(channel: UpdateChannel) {
|
|
55
|
-
await
|
|
55
|
+
await NativeUpdate.configure({
|
|
56
56
|
updateChannel: channel,
|
|
57
57
|
updateUrl: `https://updates.example.com/api/${channel}/check`
|
|
58
58
|
});
|
|
@@ -63,7 +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
|
|
66
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
67
67
|
currentVersion: await getCurrentVersion()
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -82,7 +82,7 @@ async function checkStagedUpdate() {
|
|
|
82
82
|
const deviceId = await getDeviceId();
|
|
83
83
|
const rolloutPercentage = hashDeviceId(deviceId) % 100;
|
|
84
84
|
|
|
85
|
-
const result = await
|
|
85
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
86
86
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
87
87
|
currentVersion: '1.0.0',
|
|
88
88
|
metadata: {
|
|
@@ -105,13 +105,13 @@ Download updates in the background without interrupting users:
|
|
|
105
105
|
```typescript
|
|
106
106
|
async function setupBackgroundUpdates() {
|
|
107
107
|
// Configure background update behavior
|
|
108
|
-
await
|
|
108
|
+
await NativeUpdate.configure({
|
|
109
109
|
backgroundUpdateMode: 'wifi-only',
|
|
110
110
|
autoInstallMode: 'on-restart'
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
// Schedule background update checks
|
|
114
|
-
await
|
|
114
|
+
await NativeUpdate.scheduleBackgroundCheck({
|
|
115
115
|
interval: 14400000, // 4 hours
|
|
116
116
|
requiresWifi: true,
|
|
117
117
|
requiresCharging: false
|
|
@@ -119,7 +119,7 @@ async function setupBackgroundUpdates() {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// Handle background update events
|
|
122
|
-
|
|
122
|
+
NativeUpdate.addListener('backgroundUpdateReady', (event) => {
|
|
123
123
|
// Notify user that update is ready
|
|
124
124
|
showUpdateNotification({
|
|
125
125
|
version: event.version,
|
|
@@ -135,11 +135,11 @@ Implement automatic rollback on update failures:
|
|
|
135
135
|
```typescript
|
|
136
136
|
async function safeUpdate() {
|
|
137
137
|
// Save current version info before update
|
|
138
|
-
const backup = await
|
|
138
|
+
const backup = await NativeUpdate.createBackup();
|
|
139
139
|
|
|
140
140
|
try {
|
|
141
141
|
// Attempt update
|
|
142
|
-
await
|
|
142
|
+
await NativeUpdate.installUpdate({
|
|
143
143
|
bundleId: 'new-update-id',
|
|
144
144
|
validateAfterInstall: true
|
|
145
145
|
});
|
|
@@ -151,12 +151,12 @@ async function safeUpdate() {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// Confirm successful update
|
|
154
|
-
await
|
|
154
|
+
await NativeUpdate.confirmUpdate();
|
|
155
155
|
} catch (error) {
|
|
156
156
|
console.error('Update failed, rolling back:', error);
|
|
157
157
|
|
|
158
158
|
// Automatic rollback
|
|
159
|
-
await
|
|
159
|
+
await NativeUpdate.rollback({
|
|
160
160
|
backupId: backup.id
|
|
161
161
|
});
|
|
162
162
|
|
|
@@ -201,7 +201,7 @@ async function setupABTest(config: ABTestConfig) {
|
|
|
201
201
|
? config.variants.treatment
|
|
202
202
|
: config.variants.control;
|
|
203
203
|
|
|
204
|
-
const download = await
|
|
204
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
205
205
|
url: bundleUrl,
|
|
206
206
|
metadata: {
|
|
207
207
|
testId: config.testId,
|
|
@@ -210,7 +210,7 @@ async function setupABTest(config: ABTestConfig) {
|
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
// Install with test metadata
|
|
213
|
-
await
|
|
213
|
+
await NativeUpdate.installUpdate({
|
|
214
214
|
bundleId: download.bundleId,
|
|
215
215
|
preserveData: true
|
|
216
216
|
});
|
|
@@ -227,7 +227,7 @@ class UpdateManager {
|
|
|
227
227
|
|
|
228
228
|
async checkAndPromptUpdate() {
|
|
229
229
|
// Check for update
|
|
230
|
-
const result = await
|
|
230
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
231
231
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
232
232
|
currentVersion: await this.getCurrentVersion()
|
|
233
233
|
});
|
|
@@ -253,7 +253,7 @@ class UpdateManager {
|
|
|
253
253
|
this.updateState = { status: 'downloading', progress: 0 };
|
|
254
254
|
|
|
255
255
|
// Download with progress tracking
|
|
256
|
-
const downloadListener =
|
|
256
|
+
const downloadListener = NativeUpdate.addListener(
|
|
257
257
|
'downloadProgress',
|
|
258
258
|
(progress) => {
|
|
259
259
|
this.updateState = {
|
|
@@ -265,14 +265,14 @@ class UpdateManager {
|
|
|
265
265
|
);
|
|
266
266
|
|
|
267
267
|
try {
|
|
268
|
-
const download = await
|
|
268
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
269
269
|
url: updateInfo.downloadUrl
|
|
270
270
|
});
|
|
271
271
|
|
|
272
272
|
this.updateState = { status: 'installing' };
|
|
273
273
|
this.updateUI();
|
|
274
274
|
|
|
275
|
-
await
|
|
275
|
+
await NativeUpdate.installUpdate({
|
|
276
276
|
bundleId: download.bundleId
|
|
277
277
|
});
|
|
278
278
|
|
|
@@ -300,7 +300,7 @@ async function secureUpdateCheck() {
|
|
|
300
300
|
version: getCurrentVersion()
|
|
301
301
|
});
|
|
302
302
|
|
|
303
|
-
const result = await
|
|
303
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
304
304
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
305
305
|
currentVersion: getCurrentVersion(),
|
|
306
306
|
headers: {
|
|
@@ -322,7 +322,7 @@ async function secureUpdateCheck() {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
async function downloadWithIntegrityCheck(url: string, expectedHash: string) {
|
|
325
|
-
const download = await
|
|
325
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
326
326
|
url,
|
|
327
327
|
validateChecksum: true,
|
|
328
328
|
expectedChecksum: expectedHash,
|
|
@@ -330,7 +330,7 @@ async function downloadWithIntegrityCheck(url: string, expectedHash: string) {
|
|
|
330
330
|
});
|
|
331
331
|
|
|
332
332
|
// Additional verification
|
|
333
|
-
const verified = await
|
|
333
|
+
const verified = await NativeUpdate.verifyBundle({
|
|
334
334
|
bundleId: download.bundleId,
|
|
335
335
|
publicKey: await getPublicKey()
|
|
336
336
|
});
|
|
@@ -362,7 +362,7 @@ class UpdateMetrics {
|
|
|
362
362
|
|
|
363
363
|
try {
|
|
364
364
|
// Check phase
|
|
365
|
-
const result = await
|
|
365
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
366
366
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
367
367
|
currentVersion: getCurrentVersion()
|
|
368
368
|
});
|
|
@@ -375,7 +375,7 @@ class UpdateMetrics {
|
|
|
375
375
|
|
|
376
376
|
// Download phase
|
|
377
377
|
metrics.downloadStarted = Date.now();
|
|
378
|
-
const download = await
|
|
378
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
379
379
|
url: result.downloadUrl
|
|
380
380
|
});
|
|
381
381
|
metrics.downloadCompleted = Date.now();
|
|
@@ -383,7 +383,7 @@ class UpdateMetrics {
|
|
|
383
383
|
|
|
384
384
|
// Install phase
|
|
385
385
|
metrics.installStarted = Date.now();
|
|
386
|
-
await
|
|
386
|
+
await NativeUpdate.installUpdate({
|
|
387
387
|
bundleId: download.bundleId
|
|
388
388
|
});
|
|
389
389
|
metrics.installCompleted = Date.now();
|
|
@@ -5,19 +5,19 @@ This guide demonstrates basic usage patterns for the Capacitor Native Update plu
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
yarn add
|
|
8
|
+
yarn add native-update
|
|
9
9
|
npx cap sync
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
## Simple Live Update Check
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
|
-
import {
|
|
15
|
+
import { NativeUpdate } from 'native-update';
|
|
16
16
|
|
|
17
17
|
// Check for updates on app startup
|
|
18
18
|
async function checkForUpdates() {
|
|
19
19
|
try {
|
|
20
|
-
const result = await
|
|
20
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
21
21
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
22
22
|
currentVersion: '1.0.0'
|
|
23
23
|
});
|
|
@@ -34,22 +34,22 @@ async function checkForUpdates() {
|
|
|
34
34
|
|
|
35
35
|
async function downloadAndInstall(downloadUrl: string) {
|
|
36
36
|
// Download the update
|
|
37
|
-
const download = await
|
|
37
|
+
const download = await NativeUpdate.downloadUpdate({
|
|
38
38
|
url: downloadUrl
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
// Monitor download progress
|
|
42
|
-
|
|
42
|
+
NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
43
43
|
console.log(`Download progress: ${progress.percent}%`);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
// Install the update
|
|
47
|
-
await
|
|
47
|
+
await NativeUpdate.installUpdate({
|
|
48
48
|
bundleId: download.bundleId
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// Reload the app with new bundle
|
|
52
|
-
await
|
|
52
|
+
await NativeUpdate.reloadApp();
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -58,7 +58,7 @@ async function downloadAndInstall(downloadUrl: string) {
|
|
|
58
58
|
```typescript
|
|
59
59
|
// Check if a native app update is available
|
|
60
60
|
async function checkAppStoreUpdate() {
|
|
61
|
-
const result = await
|
|
61
|
+
const result = await NativeUpdate.checkAppUpdate();
|
|
62
62
|
|
|
63
63
|
if (result.updateAvailable) {
|
|
64
64
|
// Show update prompt to user
|
|
@@ -68,7 +68,7 @@ async function checkAppStoreUpdate() {
|
|
|
68
68
|
|
|
69
69
|
if (shouldUpdate) {
|
|
70
70
|
// Open app store for update
|
|
71
|
-
await
|
|
71
|
+
await NativeUpdate.openAppStore();
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -80,7 +80,7 @@ async function checkAppStoreUpdate() {
|
|
|
80
80
|
// Request app review after positive user action
|
|
81
81
|
async function requestReview() {
|
|
82
82
|
try {
|
|
83
|
-
const result = await
|
|
83
|
+
const result = await NativeUpdate.requestReview();
|
|
84
84
|
|
|
85
85
|
if (result.displayed) {
|
|
86
86
|
console.log('Review dialog was shown');
|
|
@@ -107,7 +107,7 @@ async function onTaskCompleted() {
|
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
109
|
// Initialize with custom configuration
|
|
110
|
-
|
|
110
|
+
NativeUpdate.configure({
|
|
111
111
|
// Live update settings
|
|
112
112
|
autoCheckOnStart: true,
|
|
113
113
|
updateCheckInterval: 3600000, // 1 hour
|
|
@@ -129,7 +129,7 @@ CapacitorNativeUpdate.configure({
|
|
|
129
129
|
// Comprehensive error handling
|
|
130
130
|
async function safeUpdateCheck() {
|
|
131
131
|
try {
|
|
132
|
-
const result = await
|
|
132
|
+
const result = await NativeUpdate.checkForUpdate({
|
|
133
133
|
updateUrl: 'https://your-update-server.com/api/check',
|
|
134
134
|
currentVersion: '1.0.0'
|
|
135
135
|
});
|
|
@@ -155,26 +155,26 @@ async function safeUpdateCheck() {
|
|
|
155
155
|
// Set up event listeners
|
|
156
156
|
function setupUpdateListeners() {
|
|
157
157
|
// Download progress
|
|
158
|
-
|
|
158
|
+
NativeUpdate.addListener('downloadProgress', (event) => {
|
|
159
159
|
updateProgressBar(event.percent);
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
// Update installed
|
|
163
|
-
|
|
163
|
+
NativeUpdate.addListener('updateInstalled', (event) => {
|
|
164
164
|
console.log(`Update ${event.version} installed successfully`);
|
|
165
165
|
});
|
|
166
166
|
|
|
167
167
|
// Update failed
|
|
168
|
-
|
|
168
|
+
NativeUpdate.addListener('updateFailed', (event) => {
|
|
169
169
|
console.error(`Update failed: ${event.error}`);
|
|
170
170
|
// Optionally rollback
|
|
171
|
-
|
|
171
|
+
NativeUpdate.rollback();
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
// Clean up listeners when done
|
|
176
176
|
function cleanup() {
|
|
177
|
-
|
|
177
|
+
NativeUpdate.removeAllListeners();
|
|
178
178
|
}
|
|
179
179
|
```
|
|
180
180
|
|
|
@@ -63,7 +63,7 @@ App reviews are crucial for app store visibility and user trust. This feature he
|
|
|
63
63
|
|
|
64
64
|
```typescript
|
|
65
65
|
// Configure app reviews
|
|
66
|
-
await
|
|
66
|
+
await NativeUpdate.configure({
|
|
67
67
|
appReview: {
|
|
68
68
|
minimumDaysSinceInstall: 7,
|
|
69
69
|
minimumDaysSinceLastPrompt: 60,
|
|
@@ -75,11 +75,11 @@ await CapacitorNativeUpdate.configure({
|
|
|
75
75
|
async function requestReview() {
|
|
76
76
|
try {
|
|
77
77
|
// Check if we can request a review
|
|
78
|
-
const canRequest = await
|
|
78
|
+
const canRequest = await NativeUpdate.AppReview.canRequestReview();
|
|
79
79
|
|
|
80
80
|
if (canRequest.allowed) {
|
|
81
81
|
// Request the review
|
|
82
|
-
const result = await
|
|
82
|
+
const result = await NativeUpdate.AppReview.requestReview();
|
|
83
83
|
|
|
84
84
|
if (result.shown) {
|
|
85
85
|
console.log('Review dialog was shown');
|
|
@@ -104,7 +104,7 @@ class AppReviewManager {
|
|
|
104
104
|
|
|
105
105
|
async initialize() {
|
|
106
106
|
// Configure with advanced settings
|
|
107
|
-
await
|
|
107
|
+
await NativeUpdate.configure({
|
|
108
108
|
appReview: {
|
|
109
109
|
minimumDaysSinceInstall: 14,
|
|
110
110
|
minimumDaysSinceLastPrompt: 90,
|
|
@@ -182,7 +182,7 @@ class AppReviewManager {
|
|
|
182
182
|
|
|
183
183
|
private async analyzeReviewReadiness() {
|
|
184
184
|
// Check basic eligibility
|
|
185
|
-
const canRequest = await
|
|
185
|
+
const canRequest = await NativeUpdate.AppReview.canRequestReview();
|
|
186
186
|
|
|
187
187
|
if (!canRequest.allowed) {
|
|
188
188
|
return {
|
|
@@ -243,7 +243,7 @@ class AppReviewManager {
|
|
|
243
243
|
|
|
244
244
|
async requestReview() {
|
|
245
245
|
try {
|
|
246
|
-
const result = await
|
|
246
|
+
const result = await NativeUpdate.AppReview.requestReview();
|
|
247
247
|
|
|
248
248
|
// Track the request
|
|
249
249
|
this.trackReviewRequest(result);
|
|
@@ -367,7 +367,7 @@ class ReviewFatigueManager {
|
|
|
367
367
|
async canRequestReview(): Promise<boolean> {
|
|
368
368
|
// Check platform limits
|
|
369
369
|
const platformCheck =
|
|
370
|
-
await
|
|
370
|
+
await NativeUpdate.AppReview.canRequestReview();
|
|
371
371
|
|
|
372
372
|
if (!platformCheck.allowed) {
|
|
373
373
|
return false;
|
|
@@ -596,7 +596,7 @@ class iOSReviewManager {
|
|
|
596
596
|
async requestReview(): Promise<ReviewResult> {
|
|
597
597
|
try {
|
|
598
598
|
// Use StoreKit review controller
|
|
599
|
-
const result = await
|
|
599
|
+
const result = await NativeUpdate.AppReview.requestReview();
|
|
600
600
|
|
|
601
601
|
// iOS handles everything natively
|
|
602
602
|
return {
|
|
@@ -614,7 +614,7 @@ class iOSReviewManager {
|
|
|
614
614
|
|
|
615
615
|
private async fallbackToAppStore() {
|
|
616
616
|
// Open App Store page
|
|
617
|
-
await
|
|
617
|
+
await NativeUpdate.AppUpdate.openAppStore();
|
|
618
618
|
|
|
619
619
|
return {
|
|
620
620
|
shown: true,
|
|
@@ -633,7 +633,7 @@ class AndroidReviewManager {
|
|
|
633
633
|
async requestReview(): Promise<ReviewResult> {
|
|
634
634
|
try {
|
|
635
635
|
// Use Play Core in-app review
|
|
636
|
-
const result = await
|
|
636
|
+
const result = await NativeUpdate.AppReview.requestReview();
|
|
637
637
|
|
|
638
638
|
return {
|
|
639
639
|
shown: result.shown,
|
|
@@ -650,7 +650,7 @@ class AndroidReviewManager {
|
|
|
650
650
|
|
|
651
651
|
private async fallbackToPlayStore() {
|
|
652
652
|
// Open Play Store page
|
|
653
|
-
await
|
|
653
|
+
await NativeUpdate.AppUpdate.openAppStore();
|
|
654
654
|
|
|
655
655
|
return {
|
|
656
656
|
shown: true,
|
|
@@ -921,10 +921,10 @@ const debugConfig = {
|
|
|
921
921
|
// Test different scenarios
|
|
922
922
|
async function testReviewScenarios() {
|
|
923
923
|
// Test immediate request
|
|
924
|
-
await
|
|
924
|
+
await NativeUpdate.AppReview.requestReview();
|
|
925
925
|
|
|
926
926
|
// Test eligibility check
|
|
927
|
-
const canRequest = await
|
|
927
|
+
const canRequest = await NativeUpdate.AppReview.canRequestReview();
|
|
928
928
|
console.log('Can request review:', canRequest);
|
|
929
929
|
|
|
930
930
|
// Test custom triggers
|
|
@@ -44,7 +44,7 @@ While Live Updates handle web assets, App Updates manage the native app binary i
|
|
|
44
44
|
// Check for app updates on startup
|
|
45
45
|
async function checkForAppUpdates() {
|
|
46
46
|
try {
|
|
47
|
-
const updateInfo = await
|
|
47
|
+
const updateInfo = await NativeUpdate.AppUpdate.getAppUpdateInfo();
|
|
48
48
|
|
|
49
49
|
if (updateInfo.updateAvailable) {
|
|
50
50
|
console.log(`Update available: ${updateInfo.availableVersion}`);
|
|
@@ -52,7 +52,7 @@ async function checkForAppUpdates() {
|
|
|
52
52
|
// Handle based on priority
|
|
53
53
|
if (updateInfo.updatePriority >= 4) {
|
|
54
54
|
// High priority - immediate update
|
|
55
|
-
await
|
|
55
|
+
await NativeUpdate.AppUpdate.performImmediateUpdate();
|
|
56
56
|
} else {
|
|
57
57
|
// Optional update - show custom UI
|
|
58
58
|
showUpdateDialog(updateInfo);
|
|
@@ -73,7 +73,7 @@ class AppUpdateManager {
|
|
|
73
73
|
|
|
74
74
|
async initialize() {
|
|
75
75
|
// Configure app updates
|
|
76
|
-
await
|
|
76
|
+
await NativeUpdate.configure({
|
|
77
77
|
appUpdate: {
|
|
78
78
|
checkOnAppStart: true,
|
|
79
79
|
minimumVersion: '2.0.0',
|
|
@@ -94,7 +94,7 @@ class AppUpdateManager {
|
|
|
94
94
|
|
|
95
95
|
private setupUpdateListeners() {
|
|
96
96
|
// Android flexible update state changes
|
|
97
|
-
|
|
97
|
+
NativeUpdate.AppUpdate.addListener(
|
|
98
98
|
'flexibleUpdateStateChanged',
|
|
99
99
|
(state) => {
|
|
100
100
|
this.handleFlexibleUpdateState(state);
|
|
@@ -102,7 +102,7 @@ class AppUpdateManager {
|
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
// Download progress for flexible updates
|
|
105
|
-
|
|
105
|
+
NativeUpdate.AppUpdate.addListener(
|
|
106
106
|
'flexibleUpdateProgress',
|
|
107
107
|
(progress) => {
|
|
108
108
|
this.downloadProgress = progress.percent;
|
|
@@ -114,7 +114,7 @@ class AppUpdateManager {
|
|
|
114
114
|
async checkForUpdates() {
|
|
115
115
|
try {
|
|
116
116
|
this.updateInfo =
|
|
117
|
-
await
|
|
117
|
+
await NativeUpdate.AppUpdate.getAppUpdateInfo();
|
|
118
118
|
|
|
119
119
|
if (!this.updateInfo.updateAvailable) {
|
|
120
120
|
console.log('App is up to date');
|
|
@@ -166,7 +166,7 @@ class AppUpdateManager {
|
|
|
166
166
|
this.showImmediateUpdateUI();
|
|
167
167
|
|
|
168
168
|
// Start immediate update
|
|
169
|
-
await
|
|
169
|
+
await NativeUpdate.AppUpdate.performImmediateUpdate();
|
|
170
170
|
|
|
171
171
|
// App will restart automatically after update
|
|
172
172
|
} catch (error) {
|
|
@@ -183,7 +183,7 @@ class AppUpdateManager {
|
|
|
183
183
|
async startFlexibleUpdate() {
|
|
184
184
|
try {
|
|
185
185
|
// Start background download
|
|
186
|
-
await
|
|
186
|
+
await NativeUpdate.AppUpdate.startFlexibleUpdate();
|
|
187
187
|
|
|
188
188
|
// Show download progress UI
|
|
189
189
|
this.showFlexibleUpdateUI();
|
|
@@ -223,7 +223,7 @@ class AppUpdateManager {
|
|
|
223
223
|
|
|
224
224
|
async completeFlexibleUpdate() {
|
|
225
225
|
try {
|
|
226
|
-
await
|
|
226
|
+
await NativeUpdate.AppUpdate.completeFlexibleUpdate();
|
|
227
227
|
// App will restart with new version
|
|
228
228
|
} catch (error) {
|
|
229
229
|
console.error('Failed to complete update:', error);
|
|
@@ -265,17 +265,17 @@ const androidUpdate = {
|
|
|
265
265
|
// Immediate update flow
|
|
266
266
|
immediate: async () => {
|
|
267
267
|
// Blocks UI until update is installed
|
|
268
|
-
await
|
|
268
|
+
await NativeUpdate.AppUpdate.performImmediateUpdate();
|
|
269
269
|
// App restarts automatically
|
|
270
270
|
},
|
|
271
271
|
|
|
272
272
|
// Flexible update flow
|
|
273
273
|
flexible: async () => {
|
|
274
274
|
// Download in background
|
|
275
|
-
await
|
|
275
|
+
await NativeUpdate.AppUpdate.startFlexibleUpdate();
|
|
276
276
|
|
|
277
277
|
// Monitor progress
|
|
278
|
-
const listener = await
|
|
278
|
+
const listener = await NativeUpdate.AppUpdate.addListener(
|
|
279
279
|
'flexibleUpdateProgress',
|
|
280
280
|
(progress) => {
|
|
281
281
|
console.log(
|
|
@@ -285,7 +285,7 @@ const androidUpdate = {
|
|
|
285
285
|
);
|
|
286
286
|
|
|
287
287
|
// Complete when ready
|
|
288
|
-
await
|
|
288
|
+
await NativeUpdate.AppUpdate.completeFlexibleUpdate();
|
|
289
289
|
},
|
|
290
290
|
};
|
|
291
291
|
```
|
|
@@ -299,7 +299,7 @@ iOS requires manual version checking and App Store redirection:
|
|
|
299
299
|
const iosUpdate = {
|
|
300
300
|
// Check version manually
|
|
301
301
|
check: async () => {
|
|
302
|
-
const info = await
|
|
302
|
+
const info = await NativeUpdate.AppUpdate.getAppUpdateInfo();
|
|
303
303
|
|
|
304
304
|
if (info.updateAvailable) {
|
|
305
305
|
// Show custom update dialog
|
|
@@ -307,7 +307,7 @@ const iosUpdate = {
|
|
|
307
307
|
|
|
308
308
|
if (shouldUpdate) {
|
|
309
309
|
// Open App Store
|
|
310
|
-
await
|
|
310
|
+
await NativeUpdate.AppUpdate.openAppStore();
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
},
|
|
@@ -322,7 +322,7 @@ Web platforms show update notifications:
|
|
|
322
322
|
// Web fallback
|
|
323
323
|
const webUpdate = {
|
|
324
324
|
notify: async () => {
|
|
325
|
-
const info = await
|
|
325
|
+
const info = await NativeUpdate.AppUpdate.getAppUpdateInfo();
|
|
326
326
|
|
|
327
327
|
if (info.updateAvailable) {
|
|
328
328
|
// Show notification
|
|
@@ -455,13 +455,13 @@ async function enforceMinimumVersion() {
|
|
|
455
455
|
},
|
|
456
456
|
};
|
|
457
457
|
|
|
458
|
-
const info = await
|
|
458
|
+
const info = await NativeUpdate.AppUpdate.getAppUpdateInfo();
|
|
459
459
|
|
|
460
460
|
// Check if current version is below minimum
|
|
461
461
|
if (isVersionBelow(info.currentVersion, config.appUpdate.minimumVersion)) {
|
|
462
462
|
// Force immediate update
|
|
463
463
|
try {
|
|
464
|
-
await
|
|
464
|
+
await NativeUpdate.AppUpdate.performImmediateUpdate();
|
|
465
465
|
} catch (error) {
|
|
466
466
|
// If update fails or is cancelled, restrict app usage
|
|
467
467
|
showMinimumVersionRequired();
|
|
@@ -550,7 +550,7 @@ class UpdateProgressUI {
|
|
|
550
550
|
showProgress() {
|
|
551
551
|
this.createProgressUI();
|
|
552
552
|
|
|
553
|
-
|
|
553
|
+
NativeUpdate.AppUpdate.addListener(
|
|
554
554
|
'flexibleUpdateProgress',
|
|
555
555
|
(progress) => {
|
|
556
556
|
this.updateProgress(progress);
|
|
@@ -587,7 +587,7 @@ class UpdateProgressUI {
|
|
|
587
587
|
```typescript
|
|
588
588
|
async function handleAppUpdateErrors() {
|
|
589
589
|
try {
|
|
590
|
-
await
|
|
590
|
+
await NativeUpdate.AppUpdate.performImmediateUpdate();
|
|
591
591
|
} catch (error) {
|
|
592
592
|
switch (error.code) {
|
|
593
593
|
case 'UPDATE_NOT_AVAILABLE':
|
|
@@ -635,7 +635,7 @@ class UpdateRetryStrategy {
|
|
|
635
635
|
|
|
636
636
|
async retryUpdate() {
|
|
637
637
|
try {
|
|
638
|
-
await
|
|
638
|
+
await NativeUpdate.AppUpdate.startFlexibleUpdate();
|
|
639
639
|
this.retryCount = 0;
|
|
640
640
|
} catch (error) {
|
|
641
641
|
if (this.shouldRetry(error)) {
|