native-update-capacitor 4.4.6 → 5.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.
@@ -10,10 +10,11 @@ yarn add native-update
10
10
 
11
11
  ## Core Concepts
12
12
 
13
- Native Update provides three main features:
13
+ Native Update provides four main feature areas:
14
14
  1. **Live Updates (OTA)** - Deploy JS/HTML/CSS updates without app store approval
15
15
  2. **App Updates** - Native app store update management (Google Play, App Store)
16
16
  3. **App Reviews** - In-app review prompts
17
+ 4. **Background Update** - Scheduled native availability checks and optional notifications
17
18
 
18
19
  ## Quick Start
19
20
 
@@ -25,7 +26,7 @@ import { NativeUpdate } from 'native-update';
25
26
  // Configure the plugin (nested UpdateConfig — one section per feature)
26
27
  await NativeUpdate.configure({
27
28
  liveUpdate: {
28
- appId: 'com.your.app',
29
+ appId: '550e8400-e29b-41d4-a716-446655440000', // UUID issued by the dashboard; not the native package ID
29
30
  // Canonical rule: serverUrl is the backend base; the plugin appends
30
31
  // /v1/updates/check. Hosted backend: https://nativeupdatebe.aoneahsan.com/api
31
32
  serverUrl: 'https://nativeupdatebe.aoneahsan.com/api',
@@ -35,8 +36,7 @@ await NativeUpdate.configure({
35
36
  publicKey: import.meta.env.VITE_NATIVE_UPDATE_PUBLIC_KEY,
36
37
  requireSignature: true,
37
38
  channel: 'production', // e.g. 'development' | 'staging' | 'production'
38
- autoUpdate: true,
39
- updateStrategy: 'background', // 'immediate' | 'background' | 'manual'
39
+ autoUpdate: false, // native sync() checks only; download and apply explicitly
40
40
  },
41
41
  });
42
42
  ```
@@ -46,43 +46,41 @@ await NativeUpdate.configure({
46
46
  ```typescript
47
47
  import { NativeUpdate } from 'native-update';
48
48
 
49
- // Check and apply updates — sync() reports a status enum
50
- const result = await NativeUpdate.sync();
51
- if (result.status === 'UPDATE_INSTALLED') {
52
- // sync() already downloaded + staged the bundle
53
- await NativeUpdate.reload();
54
- }
49
+ // Confirm the current bundle after a successful render.
50
+ await NativeUpdate.notifyAppReady();
55
51
 
56
- // Manual update flow
52
+ // Native sync() only checks. Use the explicit cross-platform flow.
57
53
  const latest = await NativeUpdate.checkForUpdate();
58
54
  if (latest.available) {
59
55
  // Fetches the complete signed manifest and uses a compatible NUDELTA/1
60
56
  // patch when available, with verified full-bundle fallback.
61
- await NativeUpdate.downloadUpdate();
62
- await NativeUpdate.applyUpdate();
57
+ const bundle = await NativeUpdate.downloadUpdate();
58
+ await NativeUpdate.set({ ...bundle, applyOn: 'next-start' });
63
59
  }
64
-
65
- // Notify app is stable after update (prevents auto-rollback)
66
- await NativeUpdate.notifyAppReady();
67
60
  ```
68
61
 
69
62
  ### App Store Updates
70
63
 
71
64
  ```typescript
72
65
  import { NativeUpdate } from 'native-update';
66
+ import { Capacitor } from '@capacitor/core';
73
67
 
74
68
  // Check for app store updates
75
69
  const updateInfo = await NativeUpdate.getAppUpdateInfo();
76
- if (updateInfo.updateAvailable) {
77
- if ((updateInfo.updatePriority ?? 0) >= 4) {
78
- // Critical update - force immediate
70
+ if (updateInfo.updateAvailable && Capacitor.getPlatform() === 'android') {
71
+ if (updateInfo.immediateUpdateAllowed && (updateInfo.updatePriority ?? 0) >= 4) {
79
72
  await NativeUpdate.performImmediateUpdate();
80
- } else {
81
- // Flexible update - download in background
73
+ } else if (updateInfo.flexibleUpdateAllowed) {
74
+ const ready = await NativeUpdate.addListener('appUpdateReady', () => {
75
+ showRestartPrompt(async () => {
76
+ await ready.remove();
77
+ await NativeUpdate.completeFlexibleUpdate();
78
+ });
79
+ });
82
80
  await NativeUpdate.startFlexibleUpdate();
83
- // Later, when ready to install
84
- await NativeUpdate.completeFlexibleUpdate();
85
81
  }
82
+ } else if (updateInfo.updateAvailable) {
83
+ await NativeUpdate.openAppStore();
86
84
  }
87
85
  ```
88
86
 
@@ -105,7 +103,7 @@ if (eligibility.canRequest) {
105
103
 
106
104
  | Method | Description | Returns |
107
105
  |--------|-------------|---------|
108
- | `sync(options?)` | Check and apply updates | `Promise<SyncResult>` |
106
+ | `sync(options?)` | Check for updates on Android and iOS; use explicit download and apply methods | `Promise<SyncResult>` |
109
107
  | `download(options)` | Download specific version | `Promise<BundleInfo>` |
110
108
  | `set({ ...bundle, applyOn? })` | Make a bundle the app's bundle: `'now'` (default) switches at once, `'next-start'` (4.4.5+) stages it for the next cold start | `Promise<void>` |
111
109
  | `reload()` | Reload app with current bundle | `Promise<void>` |
@@ -153,7 +151,7 @@ interface LiveUpdateConfig {
153
151
  serverUrl?: string; // Backend base URL; checks hit {serverUrl}/v1/updates/check (HTTPS required in production)
154
152
  apiKey?: string; // Sent as X-API-Key on every check (dashboard: Apps → your app → API Keys). Since v3.1.3
155
153
  channel?: string; // Update channel (default: 'production')
156
- autoUpdate?: boolean; // Auto-check + apply updates
154
+ autoUpdate?: boolean; // Compatibility field; native sync() checks only
157
155
  updateStrategy?: 'immediate' | 'background' | 'manual';
158
156
  publicKey?: string; // RSA public key for RSA-SHA256 verification
159
157
  requireSignature?: boolean; // Reject unsigned bundles (default: true)
@@ -162,7 +160,7 @@ interface LiveUpdateConfig {
162
160
  maxBundleSize?: number; // Maximum compressed download (default: 100 MiB)
163
161
  maxUncompressedBundleSize?: number; // Native extraction cap (default: 500 MiB)
164
162
  checksumAlgorithm?: 'SHA-256' | 'SHA-512'; // (default: 'SHA-256')
165
- checkInterval?: number; // Auto-check interval
163
+ checkInterval?: number; // Compatibility field in ms; does not schedule native checks
166
164
  }
167
165
  ```
168
166
 
@@ -199,11 +197,13 @@ const stateListener = await NativeUpdate.addListener('updateStateChanged', (even
199
197
 
200
198
  ## Update Channels
201
199
 
202
- | Channel | Purpose | Auto-Update | Check Interval |
203
- |---------|---------|-------------|----------------|
204
- | `development` | Internal testing | Yes | 1 minute |
205
- | `staging` | QA/Beta testing | Configurable | 1 hour |
206
- | `production` | Live users | No (consent) | Daily |
200
+ | Channel | Typical use |
201
+ |---------|-------------|
202
+ | `development` | Internal builds and test bundles |
203
+ | `staging` | Release validation |
204
+ | `production` | Live users |
205
+
206
+ Channel names do not set an automatic check interval or install policy. The native app chooses when to call `checkForUpdate()`, `downloadUpdate()`, and `applyUpdate()`.
207
207
 
208
208
  ## Backend Requirements
209
209
 
@@ -254,10 +254,11 @@ your own backend just to hide it. In the dashboard (**Apps → API Keys →
254
254
  Restrictions**) you can lock each key to the clients that may use it:
255
255
 
256
256
  - **Web** — allowed origins (exact `https://app.example.com` or a
257
- `https://*.example.com` wildcard). Enforced against the browser's `Origin`
258
- header, so the update API is safe to call directly from your web app. (The
259
- `/v1/*` API sends permissive CORS precisely so browsers can call it; the real
260
- gate is this per-key check, not CORS.)
257
+ `https://*.example.com` wildcard). Browsers attach an `Origin` header, so
258
+ your web app can call the update API directly. A non-browser client can forge
259
+ that header; an origin restriction limits ordinary browser use but is not
260
+ proof of a caller's identity. The `/v1/*` API permits CORS; the per-key
261
+ restriction performs the server-side check.
261
262
  - **Android** — allowed apps by package name + signing-cert SHA-256/SHA-1
262
263
  (`keytool -list -printcert`; add both your upload key and the Play App
263
264
  Signing cert).
@@ -290,7 +291,8 @@ blocked by an Android/iOS restriction — web restrictions work with any version
290
291
  The native identity headers are **client-attested** (parity with Google Maps
291
292
  API-key app restrictions): they stop cross-site/casual key reuse and quota
292
293
  abuse, not a determined attacker replaying headers by hand. Only the web
293
- `Origin` check is browser-enforced.
294
+ `Origin` header is browser-controlled in browsers, but can be forged outside
295
+ them.
294
296
 
295
297
  ## CLI Tools
296
298
 
@@ -358,13 +360,13 @@ curl -H "Authorization: Bearer $NATIVE_UPDATE_TOKEN" \
358
360
  { "data": {
359
361
  "name": "GitHub Actions",
360
362
  "permissions": ["manage"],
361
- "apps": [{ "id": 12, "app_id": "com.example.app", "name": "Example" }]
363
+ "apps": [{ "id": 12, "app_id": "550e8400-e29b-41d4-a716-446655440000", "name": "Example" }]
362
364
  } }
363
365
  ```
364
366
 
365
367
  ### Endpoints
366
368
 
367
- `{app}` accepts the numeric id **or** the string `app_id` (`com.example.app`).
369
+ `{app}` accepts the numeric id **or** the string `app_id` (a server-generated UUID, for example `550e8400-e29b-41d4-a716-446655440000`).
368
370
 
369
371
  | Method | Path | Does |
370
372
  |---|---|---|
@@ -410,7 +412,7 @@ curl -X POST \
410
412
  -F "version=1.2.0" \
411
413
  -F "channel=production" \
412
414
  -F "release_notes=Bug fixes" \
413
- https://nativeupdatebe.aoneahsan.com/api/public/v1/apps/com.example.app/builds
415
+ https://nativeupdatebe.aoneahsan.com/api/public/v1/apps/550e8400-e29b-41d4-a716-446655440000/builds
414
416
  ```
415
417
 
416
418
  ```json
@@ -449,38 +451,38 @@ npx native-update token info # who am I, which apps?
449
451
  # Apps
450
452
  npx native-update apps list
451
453
  npx native-update apps create --name "Example" --bundle-id com.example.app --platform both
452
- npx native-update apps show com.example.app
453
- npx native-update apps update com.example.app --name "Example (renamed)"
454
- npx native-update apps delete com.example.app
454
+ npx native-update apps show 550e8400-e29b-41d4-a716-446655440000
455
+ npx native-update apps update 550e8400-e29b-41d4-a716-446655440000 --name "Example (renamed)"
456
+ npx native-update apps delete 550e8400-e29b-41d4-a716-446655440000
455
457
 
456
458
  # API keys
457
- npx native-update apps keys list com.example.app
458
- npx native-update apps keys create com.example.app --name production # prints the secret once
459
- npx native-update apps keys show com.example.app 6
460
- npx native-update apps keys rotate com.example.app 6
461
- npx native-update apps keys reveal com.example.app 6
462
- npx native-update apps keys restrict com.example.app 6 --origins https://app.example.com
463
- npx native-update apps keys revoke com.example.app 6
464
- npx native-update apps keys deprecate com.example.app 6
465
- npx native-update apps keys delete com.example.app 6
459
+ npx native-update apps keys list 550e8400-e29b-41d4-a716-446655440000
460
+ npx native-update apps keys create 550e8400-e29b-41d4-a716-446655440000 --name production # prints the secret once
461
+ npx native-update apps keys show 550e8400-e29b-41d4-a716-446655440000 6
462
+ npx native-update apps keys rotate 550e8400-e29b-41d4-a716-446655440000 6
463
+ npx native-update apps keys reveal 550e8400-e29b-41d4-a716-446655440000 6
464
+ npx native-update apps keys restrict 550e8400-e29b-41d4-a716-446655440000 6 --origins https://app.example.com
465
+ npx native-update apps keys revoke 550e8400-e29b-41d4-a716-446655440000 6
466
+ npx native-update apps keys deprecate 550e8400-e29b-41d4-a716-446655440000 6
467
+ npx native-update apps keys delete 550e8400-e29b-41d4-a716-446655440000 6
466
468
 
467
469
  # Signing key (public key + fingerprint only) and keystore backup
468
- npx native-update apps signing show com.example.app
469
- npx native-update apps signing create com.example.app --name release
470
- npx native-update apps signing rotate com.example.app
471
- npx native-update apps keystore upload com.example.app ./example-release.zip
472
- npx native-update apps keystore info com.example.app
473
- npx native-update apps keystore download com.example.app ./keystore.zip
474
- npx native-update apps keystore delete com.example.app
470
+ npx native-update apps signing show 550e8400-e29b-41d4-a716-446655440000
471
+ npx native-update apps signing create 550e8400-e29b-41d4-a716-446655440000 --name release
472
+ npx native-update apps signing rotate 550e8400-e29b-41d4-a716-446655440000
473
+ npx native-update apps keystore upload 550e8400-e29b-41d4-a716-446655440000 ./example-release.zip
474
+ npx native-update apps keystore info 550e8400-e29b-41d4-a716-446655440000
475
+ npx native-update apps keystore download 550e8400-e29b-41d4-a716-446655440000 ./keystore.zip
476
+ npx native-update apps keystore delete 550e8400-e29b-41d4-a716-446655440000
475
477
 
476
478
  # Builds — deploy: zips the directory, uploads, and (with --wait) blocks until
477
479
  # live. Exits non-zero if the release fails, so CI fails too.
478
- npx native-update deploy ./dist --app com.example.app --version 1.2.0 --wait
480
+ npx native-update deploy ./dist --app 550e8400-e29b-41d4-a716-446655440000 --version 1.2.0 --wait
479
481
 
480
- npx native-update builds list com.example.app
481
- npx native-update builds promote com.example.app 42 --to production
482
- npx native-update builds rollout com.example.app 42 --percent 10
483
- npx native-update builds status com.example.app 42 --set paused
482
+ npx native-update builds list 550e8400-e29b-41d4-a716-446655440000
483
+ npx native-update builds promote 550e8400-e29b-41d4-a716-446655440000 42 --to production
484
+ npx native-update builds rollout 550e8400-e29b-41d4-a716-446655440000 42 --percent 10
485
+ npx native-update builds status 550e8400-e29b-41d4-a716-446655440000 42 --set paused
484
486
  npx native-update jobs status 01hq2xk8... --wait
485
487
  ```
486
488
 
@@ -510,17 +512,24 @@ app is missing.
510
512
 
511
513
  ### Android
512
514
 
513
- No additional setup required. The plugin's own Gradle config already includes
514
- the Google Play App Update and Play Review libraries (do NOT add the legacy
515
- `com.google.android.play:core` artifact — it conflicts with them).
515
+ The plugin's Gradle config includes the Google Play App Update and Play Review
516
+ libraries (do not add the legacy `com.google.android.play:core` artifact). For
517
+ background checks, review the merged permissions and worker setup in the
518
+ [Android guide](https://nativeupdate-docs.aoneahsan.com/platforms/android).
516
519
 
517
520
  ### iOS
518
521
 
519
- No additional setup required. Uses native APIs.
522
+ Store redirects and review prompts use native APIs. Background checks require
523
+ the host app's `BGTaskSchedulerPermittedIdentifiers` entry and Background fetch
524
+ capability; see the [iOS guide](https://nativeupdate-docs.aoneahsan.com/platforms/ios).
520
525
 
521
- ### Web (Limited Support)
526
+ ### Web
522
527
 
523
- Web platform supports checking for updates only. Actual OTA updates require native platforms.
528
+ The web implementation can check service-worker registrations for updates and
529
+ offers bundle download APIs. Its `applyUpdate()` records a verified bundle and
530
+ reloads the current page; it does not install assets into a native WebView or
531
+ replace the site's deployed files. Keep Android Play and iOS App Store flows on
532
+ the corresponding native platform.
524
533
 
525
534
  ## Security Best Practices
526
535
 
@@ -540,19 +549,19 @@ import { NativeUpdate } from 'native-update';
540
549
 
541
550
  App.addListener('appStateChange', async ({ isActive }) => {
542
551
  if (isActive) {
543
- const result = await NativeUpdate.sync();
544
- if (result.status === 'UPDATE_INSTALLED') {
545
- // Show user prompt to reload (NativeUpdate.reload())
546
- }
552
+ const update = await NativeUpdate.checkForUpdate();
553
+ if (!update.available) return;
554
+ const bundle = await NativeUpdate.downloadUpdate();
555
+ await NativeUpdate.set({ ...bundle, applyOn: 'next-start' });
547
556
  }
548
557
  });
549
558
  ```
550
559
 
551
- ### Review After Positive Action
560
+ ### Review After a Completed Task
552
561
 
553
562
  ```typescript
554
- async function handlePurchaseComplete() {
555
- // After successful purchase
563
+ async function handleTaskComplete() {
564
+ // Call only after the user finishes an ordinary task in your app.
556
565
  const eligibility = await NativeUpdate.canRequestReview();
557
566
  if (eligibility.canRequest) {
558
567
  await NativeUpdate.requestReview();
@@ -11,8 +11,8 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '14.0'
15
- s.dependency 'Capacitor'
14
+ s.ios.deployment_target = '16.0'
15
+ s.dependency 'Capacitor', '>= 9.0', '< 10.0'
16
16
  s.dependency 'ZIPFoundation', '~> 0.9.19'
17
17
  s.swift_version = '5.9'
18
18
  s.frameworks = 'LocalAuthentication', 'Security'
package/README.md CHANGED
@@ -43,11 +43,11 @@ are available as an HTTP API for CI and coding agents.
43
43
 
44
44
  | | |
45
45
  |---|---|
46
- | **Version** | `4.4.6` |
47
- | **License** | Proprietary — free to use in your apps ([LICENSE](./LICENSE)) |
46
+ | **Version** | `5.0.1` |
47
+ | **License** | Proprietary — free to use in your apps ([Native Update License](https://unpkg.com/native-update@latest/LICENSE)) |
48
48
  | **Node** | `>=24.16.0` (install + CLI toolchain) |
49
- | **Platforms** | iOS 14+ · Android 8.0+ (API 26) · Web |
50
- | **Package size** | 281 kB tarball · ~1.14 MB unpacked · 136 files |
49
+ | **Platforms** | iOS 16+ (implementation pending device proof) · Android 8.0+ (API 26) · Web |
50
+ | **Package size** | See the published npm tarball |
51
51
  | **Types** | Bundled `.d.ts` · ESM + CommonJS entry points |
52
52
  | **Status** | Stable · actively maintained |
53
53
 
@@ -128,7 +128,7 @@ policies is your responsibility — see [Limitations](#limitations).
128
128
  | Platform | Live updates | App updates | App reviews | Notes |
129
129
  |---|---|---|---|---|
130
130
  | Android | ✅ | ✅ | ✅ | Google Play Core immediate and flexible flows |
131
- | iOS | ✅ | ✅ | ✅ | App Store version check; native review dialog |
131
+ | iOS | Implemented | Implemented | Implemented | Requires Xcode 27 and device verification before a support claim |
132
132
  | Web | ✅ | ⚠️ | ⚠️ | Bundle handling works; store-update and review calls resolve as no-ops so shared code need not branch |
133
133
 
134
134
  Certificate pinning and accurate storage measurement are native-only — the web build reports both as
@@ -140,11 +140,11 @@ unavailable rather than pretending. See [Limitations](#limitations).
140
140
  | Requirement | Version | Why |
141
141
  |---|---|---|
142
142
  | Node | `>=24.16.0` | declared in `engines`; installers that enforce `engines` refuse an older runtime. Needed to install and to run the CLI — not by your app at runtime |
143
- | `@capacitor/core` | `^8.0.1` | peer — the host app owns the Capacitor version |
144
- | `@capacitor/filesystem` | `>=8.0.0` | peer — stores and extracts downloaded bundles |
145
- | `@capacitor/preferences` | `>=8.0.0` | peer — records which bundle is active and whether it was confirmed |
146
- | iOS | 14.0+ | minimum deployment target of the native plugin |
147
- | Android | 8.0+ (API 26) | Capacitor 8.5 minimum; compile/target SDK 36 and Java 21 |
143
+ | `@capacitor/core` | `^9.0.0` | peer — the host app owns the Capacitor version |
144
+ | `@capacitor/filesystem` | `^9.0.0` | peer — stores and extracts downloaded bundles |
145
+ | `@capacitor/preferences` | `^9.0.0` | peer — records which bundle is active and whether it was confirmed |
146
+ | iOS | 16.0+ | minimum deployment target of the native plugin |
147
+ | Android | 8.0+ (API 26) | compile SDK 37, AGP 9.4.1 and Java 21 |
148
148
  | An update server | — | the hosted Native Update service, or your own implementation of the HTTP contract |
149
149
 
150
150
  <a id="installation"></a>
@@ -175,7 +175,7 @@ import { Preferences } from '@capacitor/preferences';
175
175
  await NativeUpdate.initialize({
176
176
  filesystem: Filesystem,
177
177
  preferences: Preferences,
178
- appId: 'com.example.app',
178
+ appId: '550e8400-e29b-41d4-a716-446655440000',
179
179
  serverUrl: 'https://nativeupdatebe.aoneahsan.com/api',
180
180
  apiKey: import.meta.env.VITE_NATIVE_UPDATE_API_KEY,
181
181
  publicKey: import.meta.env.VITE_NATIVE_UPDATE_PUBLIC_KEY,
@@ -187,9 +187,10 @@ await NativeUpdate.initialize({
187
187
  // bundle after two cold starts.
188
188
  await NativeUpdate.notifyAppReady();
189
189
 
190
- const result = await NativeUpdate.sync();
191
- if (result.status === 'UPDATE_INSTALLED') {
192
- await NativeUpdate.reload();
190
+ const update = await NativeUpdate.checkForUpdate();
191
+ if (update.available) {
192
+ const bundle = await NativeUpdate.downloadUpdate();
193
+ await NativeUpdate.applyUpdate(bundle.bundleId);
193
194
  }
194
195
  ```
195
196
 
@@ -198,15 +199,16 @@ if (result.status === 'UPDATE_INSTALLED') {
198
199
 
199
200
  ### Prompt before applying an update
200
201
 
201
- `sync()` reports what it found; you decide whether to interrupt the user.
202
+ Check first, then ask before downloading and applying. On Android, `sync()` only checks and does not install an update.
202
203
 
203
204
  ```ts
204
- const result = await NativeUpdate.sync();
205
+ const update = await NativeUpdate.checkForUpdate();
205
206
 
206
- if (result.status === 'UPDATE_INSTALLED') {
207
- const proceed = result.mandatory || (await askTheUser(result.version));
207
+ if (update.available && update.latestVersion) {
208
+ const proceed = update.mandatory || (await askTheUser(update.latestVersion));
208
209
  if (proceed) {
209
- await NativeUpdate.reload();
210
+ const bundle = await NativeUpdate.downloadUpdate();
211
+ await NativeUpdate.applyUpdate(bundle.bundleId);
210
212
  }
211
213
  }
212
214
  ```
@@ -245,6 +247,12 @@ if (info.updateAvailable) {
245
247
  if (info.immediateUpdateAllowed) {
246
248
  await NativeUpdate.performImmediateUpdate();
247
249
  } else if (info.flexibleUpdateAllowed) {
250
+ const ready = await NativeUpdate.addListener('appUpdateReady', () => {
251
+ showRestartPrompt(async () => {
252
+ await ready.remove();
253
+ await NativeUpdate.completeFlexibleUpdate();
254
+ });
255
+ });
248
256
  await NativeUpdate.startFlexibleUpdate();
249
257
  } else {
250
258
  await NativeUpdate.openAppStore();
@@ -282,7 +290,7 @@ if (result.held) {
282
290
  <a id="configuration"></a>
283
291
  ## ⚙️ Configuration&nbsp;[#](#configuration)
284
292
 
285
- Passed to `initialize()`. The complete set is in the
293
+ On Android, `plugins.NativeUpdate` in `capacitor.config.ts` supplies packaged defaults. A complete block can run update checks before JavaScript calls `initialize()`; values passed to `initialize()` override matching keys. Web builds still pass their own configuration. The app API key is a client credential, so restrict it to your app in the dashboard. The complete set is in the
286
294
  [configuration reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/config).
287
295
 
288
296
  | Option | Type | Default | What it does |
@@ -291,7 +299,7 @@ Passed to `initialize()`. The complete set is in the
291
299
  | `preferences` | `Preferences` | — | the `@capacitor/preferences` instance used to record bundle state |
292
300
  | `appId` | `string` | — | identifies your app to the update server |
293
301
  | `serverUrl` | `string` | — | base URL of the backend; the plugin appends `/v1/updates/check` |
294
- | `apiKey` | `string` | — | sent as `X-API-Key`. Not persisted — pass it on every `initialize()` |
302
+ | `apiKey` | `string` | — | sent as `X-API-Key`. Not persisted; pass it on every web boot or package it in the Android Capacitor config block |
295
303
  | `channel` | `string` | `'production'` | which release channel this install follows |
296
304
  | `autoCheck` | `boolean` | `false` | check for updates without an explicit `sync()` |
297
305
  | `autoUpdate` | `boolean` | `false` | apply what it finds without asking |
@@ -392,7 +400,7 @@ export NATIVE_UPDATE_TOKEN=nu_pat_…
392
400
 
393
401
  # Zips ./dist, uploads it, and blocks until the release is live.
394
402
  # Exits non-zero on failure, so a broken release fails the build.
395
- npx native-update deploy ./dist --app com.example.app --version 1.2.0 --wait
403
+ npx native-update deploy ./dist --app 550e8400-e29b-41d4-a716-446655440000 --version 1.2.0 --wait
396
404
  ```
397
405
 
398
406
  | Flag | Default | What it does |
@@ -540,7 +548,7 @@ indexed at [`/raw/manifest.json`](https://nativeupdate-docs.aoneahsan.com/raw/ma
540
548
  <a id="changelog"></a>
541
549
  ## 🔄 Changelog&nbsp;[#](#changelog)
542
550
 
543
- Latest release: **`4.4.6`** (README: every released place; no code changes). 4.4.5: `set()` takes `applyOn: 'next-start'`, which stages a bundle for the next cold start instead of reloading the running app. Before that, 4.4.4: `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
551
+ Current release: **`5.0.1`**. Android now reads packaged Capacitor configuration, and flexible Play updates wait for a user-confirmed restart. The Capacitor 9 migration landed in v5; see the [migration guide](https://unpkg.com/native-update@latest/docs/MIGRATION.md). In 4.4.5, `set()` gained `applyOn: 'next-start'`, which stages a bundle for the next cold start instead of reloading the running app. Before that, 4.4.4: `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
544
552
  (comments and message strings are skipped, `versionName appVersionName` is followed to its value). **`4.4.3`**: Android logs `Built <id> from a N-byte patch` when an update arrives as a `NUDELTA/1`
545
553
  patch, so you can see deltas working on a device. No API change.
546
554
 
@@ -4,21 +4,15 @@ buildscript {
4
4
  mavenCentral()
5
5
  }
6
6
  dependencies {
7
- classpath 'com.android.tools.build:gradle:8.13.2'
8
- classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.20'
7
+ classpath 'com.android.tools.build:gradle:9.4.1'
9
8
  }
10
9
  }
11
10
 
12
11
  ext {
13
- kotlinVersion = '2.2.20'
14
- compileSdkVersion = 36
15
- targetSdkVersion = 36
16
- // Capacitor Android 8.5 declares API 26; the plugin cannot advertise or
17
- // assemble against a lower manifest floor than its required peer.
18
- minSdkVersion = 26
19
- androidxAppCompatVersion = '1.7.1'
20
- // 1.19 requires compileSdk 37 + AGP 9.1; Capacitor 8's supported line is AGP 8/API 36.
21
- androidxCoreVersion = '1.17.0'
12
+ compileSdkVersion = rootProject.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 37
13
+ minSdkVersion = rootProject.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 26
14
+ androidxAppCompatVersion = rootProject.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.8.0'
15
+ androidxCoreVersion = rootProject.hasProperty('androidxCoreVersion') ? rootProject.ext.androidxCoreVersion : '1.19.1'
22
16
  androidxWorkVersion = '2.11.2'
23
17
  playAppUpdateVersion = '2.1.0'
24
18
  playAppUpdateKtxVersion = '2.1.0'
@@ -28,7 +22,6 @@ ext {
28
22
  }
29
23
 
30
24
  apply plugin: 'com.android.library'
31
- apply plugin: 'kotlin-android'
32
25
 
33
26
  android {
34
27
  namespace = "com.aoneahsan.nativeupdate"
@@ -36,9 +29,8 @@ android {
36
29
 
37
30
  defaultConfig {
38
31
  minSdkVersion project.minSdkVersion
39
- targetSdkVersion project.targetSdkVersion
40
32
  versionCode 1
41
- versionName "1.0"
33
+ versionName "5.0.1"
42
34
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
43
35
  // Shipped to every consuming app's R8 run (ISSUE-09).
44
36
  consumerProguardFiles 'consumer-rules.pro'
@@ -59,8 +51,7 @@ android {
59
51
  lint {
60
52
  abortOnError = true
61
53
  warningsAsErrors = true
62
- // Capacitor 8 consumers are still on AGP 8; AGP 9 is a deliberate v5 migration.
63
- // KTX preference hints are style-only and do not affect correctness.
54
+ // Version availability hints are checked during the dependency audit.
64
55
  disable += ['AndroidGradlePluginVersion', 'GradleDependency', 'NewerVersionAvailable', 'UseKtx']
65
56
  }
66
57
 
@@ -69,10 +60,6 @@ android {
69
60
  targetCompatibility JavaVersion.VERSION_21
70
61
  }
71
62
 
72
- kotlinOptions {
73
- jvmTarget = '21'
74
- }
75
-
76
63
  testOptions {
77
64
  unitTests {
78
65
  includeAndroidResources = true
@@ -90,14 +77,13 @@ dependencies {
90
77
  implementation fileTree(dir: 'libs', include: ['*.jar'])
91
78
  implementation project(':capacitor-android')
92
79
 
93
- // Kotlin
94
- implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.2.20'
80
+ // Kotlin is built into Android Gradle Plugin 9.
95
81
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.11.0'
96
82
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.11.0'
97
83
 
98
84
  // AndroidX
99
85
  implementation "androidx.appcompat:appcompat:${androidxAppCompatVersion}"
100
- implementation "androidx.core:core-ktx:${androidxCoreVersion}"
86
+ implementation "androidx.core:core:${androidxCoreVersion}"
101
87
  implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
102
88
 
103
89
  // Google Play Services - Using explicit versions to avoid resolution issues
@@ -1,7 +1,7 @@
1
1
  # Gradle Wrapper Properties
2
2
  distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-all.zip
4
+ distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
5
5
  networkTimeout=10000
6
6
  validateDistributionUrl=true
7
7
  zipStoreBase=GRADLE_USER_HOME
@@ -119,8 +119,17 @@ class AppUpdatePlugin(
119
119
  }
120
120
 
121
121
  fun completeFlexibleUpdate(call: PluginCall) {
122
- appUpdateManager.completeUpdate()
123
- call.resolve()
122
+ appUpdateManager.appUpdateInfo.addOnSuccessListener { info ->
123
+ if (info.installStatus() != InstallStatus.DOWNLOADED) {
124
+ call.reject("UPDATE_NOT_AVAILABLE", "No downloaded flexible update is ready to install")
125
+ return@addOnSuccessListener
126
+ }
127
+ appUpdateManager.completeUpdate()
128
+ .addOnSuccessListener { call.resolve() }
129
+ .addOnFailureListener { error -> call.reject("UPDATE_FAILED", error.message) }
130
+ }.addOnFailureListener { error ->
131
+ call.reject("UPDATE_CHECK_FAILED", error.message)
132
+ }
124
133
  }
125
134
 
126
135
  fun openAppStore(call: PluginCall) {
@@ -205,10 +214,7 @@ class AppUpdatePlugin(
205
214
 
206
215
  when (state.installStatus()) {
207
216
  InstallStatus.DOWNLOADED -> {
208
- // Update has been downloaded, prompt user to restart
209
- popupSnackbarForCompleteUpdate()
210
-
211
- // Emit ready event
217
+ // The host app asks when to restart and calls completeFlexibleUpdate().
212
218
  val readyData = JSObject()
213
219
  readyData.put("message", "Update downloaded and ready to install")
214
220
  eventListener?.invoke("appUpdateReady", readyData)
@@ -230,12 +236,6 @@ class AppUpdatePlugin(
230
236
  }
231
237
  }
232
238
 
233
- private fun popupSnackbarForCompleteUpdate() {
234
- // In a real implementation, show a snackbar or notification
235
- // For now, we'll just complete the update
236
- appUpdateManager.completeUpdate()
237
- }
238
-
239
239
  private fun getCurrentAppVersion(): String {
240
240
  return try {
241
241
  val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)
@@ -311,4 +311,4 @@ class AppUpdatePlugin(
311
311
  null
312
312
  }
313
313
  }
314
- }
314
+ }
@@ -13,6 +13,7 @@ import java.io.File
13
13
  import java.io.FileOutputStream
14
14
  import java.io.IOException
15
15
  import java.security.MessageDigest
16
+ import java.util.Locale
16
17
  import java.util.concurrent.TimeUnit
17
18
  import java.util.zip.ZipFile
18
19
 
@@ -61,7 +62,7 @@ class LiveUpdatePlugin(
61
62
 
62
63
  companion object {
63
64
  /** This plugin's version, sent as X-Sdk-Version. Kept equal to package.json by tests/sdk-version.test.ts. */
64
- const val SDK_VERSION = "4.4.6"
65
+ const val SDK_VERSION = "5.0.1"
65
66
 
66
67
  // SharedPreferences keys. Kept as constants so A2 (boot-time
67
68
  // re-verification) and A3 (crash-loop auto-rollback) stay in sync
@@ -595,6 +596,7 @@ class LiveUpdatePlugin(
595
596
  // SDK identity: the server offers this WebView only web bundles (docs/protocol/CLIENT-PROTOCOL.md).
596
597
  .header("X-Client-Sdk", "capacitor")
597
598
  .header("X-Sdk-Version", SDK_VERSION)
599
+ .header("Accept-Language", Locale.getDefault().toLanguageTag())
598
600
  .header("X-Android-Package", context.packageName)
599
601
  getBinaryVersion()?.let { requestBuilder.header("X-App-Version", it) }
600
602
  // App-identity headers for API-key client restrictions. Best-effort: