native-update 3.4.0 → 3.4.2
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 +551 -0
- package/android/build.gradle +6 -1
- package/dist/plugin.js +1 -1
- package/docs/CHANGELOG.md +46 -0
- package/package.json +10 -6
- package/Readme.md +0 -565
- package/cli/AGENTS.md +0 -52
- package/cli/CLAUDE.md +0 -74
- /package/dist/{plugin.cjs.js → plugin.cjs} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="https://nativeupdate-docs.aoneahsan.com/img/logo.svg" alt="Native Update logo" width="120" />
|
|
4
|
+
|
|
5
|
+
<h1>native-update</h1>
|
|
6
|
+
|
|
7
|
+
<p><strong>Over-the-air updates, app-store update flows, and in-app reviews for Capacitor apps.</strong></p>
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/native-update)
|
|
10
|
+
[](https://www.npmjs.com/package/native-update)
|
|
11
|
+
[](https://www.npmjs.com/package/native-update)
|
|
12
|
+
[](https://www.npmjs.com/package/native-update)
|
|
13
|
+
[](https://nodejs.org)
|
|
14
|
+
|
|
15
|
+
[Docs](https://nativeupdate-docs.aoneahsan.com/) · [npm](https://www.npmjs.com/package/native-update) · [Dashboard](https://nativeupdate.aoneahsan.com) · [Changelog](https://nativeupdate-docs.aoneahsan.com/changelog) · [AI Guide](https://nativeupdate-docs.aoneahsan.com/ai-integration) · [Support](https://nativeupdate.aoneahsan.com/contact)
|
|
16
|
+
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
> [!IMPORTANT]
|
|
20
|
+
> Call `NativeUpdate.notifyAppReady()` on **every** successful boot. Activating a bundle marks it
|
|
21
|
+
> pending-verification, and the native layer rolls it back after two cold starts that never confirm. Miss
|
|
22
|
+
> this one call and every update you ship silently reverts.
|
|
23
|
+
|
|
24
|
+
Native Update ships web-layer fixes to a released Capacitor app without waiting for store review, and wraps
|
|
25
|
+
the platform APIs for store updates and review prompts behind one TypeScript surface. It talks to a
|
|
26
|
+
documented HTTP contract, so you can point it at the hosted dashboard, self-host the included Laravel
|
|
27
|
+
backend, or write your own server. A bundled CLI creates, signs and deploys bundles, and the same operations
|
|
28
|
+
are available as an HTTP API for CI and coding agents.
|
|
29
|
+
|
|
30
|
+
| | |
|
|
31
|
+
|---|---|
|
|
32
|
+
| **Version** | `3.4.2` |
|
|
33
|
+
| **License** | MIT |
|
|
34
|
+
| **Node** | `>=24.16.0` (install + CLI toolchain) |
|
|
35
|
+
| **Platforms** | iOS 13+ · Android 5.0+ (API 21) · Web |
|
|
36
|
+
| **Package size** | 263 kB tarball · ~1.07 MB unpacked · 136 files |
|
|
37
|
+
| **Types** | Bundled `.d.ts` · ESM + CommonJS entry points |
|
|
38
|
+
| **Status** | Stable · actively maintained |
|
|
39
|
+
|
|
40
|
+
<a id="table-of-contents"></a>
|
|
41
|
+
## 🧭 Table of Contents [#](#table-of-contents)
|
|
42
|
+
|
|
43
|
+
- [💡 Why native-update](#why-native-update)
|
|
44
|
+
- [✨ Features](#features)
|
|
45
|
+
- [📱 Platform Support](#platform-support)
|
|
46
|
+
- [📋 Requirements](#requirements)
|
|
47
|
+
- [📦 Installation](#installation)
|
|
48
|
+
- [🚀 Quick Start](#quick-start)
|
|
49
|
+
- [🛠️ Usage](#usage)
|
|
50
|
+
- [⚙️ Configuration](#configuration)
|
|
51
|
+
- [🔧 API Reference](#api-reference)
|
|
52
|
+
- [🧩 Types](#types)
|
|
53
|
+
- [💻 Command Line](#command-line)
|
|
54
|
+
- [🧪 Examples](#examples)
|
|
55
|
+
- [🎛️ Advanced Features](#advanced-features)
|
|
56
|
+
- [🚑 Recovery & Troubleshooting](#recovery-troubleshooting)
|
|
57
|
+
- [🚧 Limitations](#limitations)
|
|
58
|
+
- [❓ FAQ](#faq)
|
|
59
|
+
- [📚 Documentation](#documentation)
|
|
60
|
+
- [🔄 Changelog](#changelog)
|
|
61
|
+
- [🤝 Contributing](#contributing)
|
|
62
|
+
- [💬 Support](#support)
|
|
63
|
+
- [📄 License](#license)
|
|
64
|
+
- [👤 Author](#author)
|
|
65
|
+
- [🔗 Links](#links)
|
|
66
|
+
- [🏷️ Keywords](#keywords)
|
|
67
|
+
|
|
68
|
+
<a id="why-native-update"></a>
|
|
69
|
+
## 💡 Why native-update [#](#why-native-update)
|
|
70
|
+
|
|
71
|
+
A Capacitor app's JavaScript, HTML and CSS live inside a native binary, so a one-line fix normally waits for
|
|
72
|
+
a store review. Over-the-air updating replaces that web layer at runtime. The three pieces a real deployment
|
|
73
|
+
needs — bundle delivery, a native update prompt when the binary itself must change, and a review request —
|
|
74
|
+
usually mean three separate integrations.
|
|
75
|
+
|
|
76
|
+
| | `native-update` | Typical alternative |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| Scope | OTA bundles, store-update flows and in-app reviews in one API | one concern per package |
|
|
79
|
+
| Backend | hosted, self-hosted, or your own server against a published HTTP contract | vendor-hosted only |
|
|
80
|
+
| Release automation | bundled CLI plus an HTTP management API for CI and agents | dashboard clicks, or a separate CLI |
|
|
81
|
+
| Bundle integrity | checksum plus optional signature, verified again at boot | varies |
|
|
82
|
+
| Cost model | free plugin; you own the backend you point it at | usage-priced service |
|
|
83
|
+
|
|
84
|
+
**Not the right tool when** your app is web-only (the OTA layer needs the native runtime), when you cannot
|
|
85
|
+
run or pay for any update server, or when your release process forbids shipping code outside a store review.
|
|
86
|
+
Apple and Google both permit OTA updates of interpreted code within their policies, but staying inside those
|
|
87
|
+
policies is your responsibility — see [Limitations](#limitations).
|
|
88
|
+
|
|
89
|
+
<a id="features"></a>
|
|
90
|
+
## ✨ Features [#](#features)
|
|
91
|
+
|
|
92
|
+
- **Live (OTA) updates** — download and activate a new web bundle at runtime, with checksum and optional
|
|
93
|
+
signature verification before it is ever loaded.
|
|
94
|
+
- **Automatic rollback** — a bundle that never confirms a healthy boot is reverted by the native layer, so a
|
|
95
|
+
bad release cannot brick installs.
|
|
96
|
+
- **Channels** — route development, staging and production installs to different bundles from one backend.
|
|
97
|
+
- **Staged rollouts** — release to a percentage of devices, then pause, resume or halt.
|
|
98
|
+
- **Native app updates** — detect a newer store build and run Google Play's immediate or flexible update
|
|
99
|
+
flow, or send the user to the App Store.
|
|
100
|
+
- **In-app reviews** — request the native review dialog without leaving the app, respecting platform limits.
|
|
101
|
+
- **Background updates** — schedule checks and notify the user when a bundle is ready.
|
|
102
|
+
- **Bring your own backend** — a documented HTTP contract, a self-hostable Laravel + Nova reference
|
|
103
|
+
implementation, and a hosted dashboard.
|
|
104
|
+
- **Release tooling** — a CLI for creating, signing, verifying and deploying bundles, plus an HTTP
|
|
105
|
+
management API covering the same lifecycle for CI and coding agents.
|
|
106
|
+
- **TypeScript throughout** — declarations for every method, option, event and error code.
|
|
107
|
+
|
|
108
|
+
<a id="platform-support"></a>
|
|
109
|
+
## 📱 Platform Support [#](#platform-support)
|
|
110
|
+
|
|
111
|
+
| Platform | Live updates | App updates | App reviews | Notes |
|
|
112
|
+
|---|---|---|---|---|
|
|
113
|
+
| Android | ✅ | ✅ | ✅ | Google Play Core immediate and flexible flows |
|
|
114
|
+
| iOS | ✅ | ✅ | ✅ | App Store version check; native review dialog |
|
|
115
|
+
| Web | ✅ | ⚠️ | ⚠️ | Bundle handling works; store-update and review calls resolve as no-ops so shared code need not branch |
|
|
116
|
+
|
|
117
|
+
Certificate pinning and accurate storage measurement are native-only — the web build reports both as
|
|
118
|
+
unavailable rather than pretending. See [Limitations](#limitations).
|
|
119
|
+
|
|
120
|
+
<a id="requirements"></a>
|
|
121
|
+
## 📋 Requirements [#](#requirements)
|
|
122
|
+
|
|
123
|
+
| Requirement | Version | Why |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| 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 |
|
|
126
|
+
| `@capacitor/core` | `^8.0.1` | peer — the host app owns the Capacitor version |
|
|
127
|
+
| `@capacitor/filesystem` | `>=8.0.0` | peer — stores and extracts downloaded bundles |
|
|
128
|
+
| `@capacitor/preferences` | `>=8.0.0` | peer — records which bundle is active and whether it was confirmed |
|
|
129
|
+
| iOS | 13.0+ | minimum deployment target of the native plugin |
|
|
130
|
+
| Android | 5.0+ (API 21) | minimum SDK of the native plugin |
|
|
131
|
+
| An update server | — | the hosted dashboard, a self-hosted backend, or your own implementation of the HTTP contract |
|
|
132
|
+
|
|
133
|
+
<a id="installation"></a>
|
|
134
|
+
## 📦 Installation [#](#installation)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
yarn add native-update @capacitor/filesystem @capacitor/preferences
|
|
138
|
+
npx cap sync
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`npx cap sync` is required. It copies the iOS and Android sources into your native projects; without it the
|
|
142
|
+
plugin loads on web and does nothing on device.
|
|
143
|
+
|
|
144
|
+
Then register an app in the [dashboard](https://nativeupdate.aoneahsan.com) to get an API key (`nu_app_…`),
|
|
145
|
+
or stand up your own server against the
|
|
146
|
+
[HTTP contract](https://nativeupdate-docs.aoneahsan.com/backend/api-contract). Keep the key in an environment
|
|
147
|
+
variable, and gate initialisation on it being non-empty so a missing key switches updates off instead of
|
|
148
|
+
crashing your app.
|
|
149
|
+
|
|
150
|
+
<a id="quick-start"></a>
|
|
151
|
+
## 🚀 Quick Start [#](#quick-start)
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { NativeUpdate } from 'native-update';
|
|
155
|
+
import { Filesystem } from '@capacitor/filesystem';
|
|
156
|
+
import { Preferences } from '@capacitor/preferences';
|
|
157
|
+
|
|
158
|
+
await NativeUpdate.initialize({
|
|
159
|
+
filesystem: Filesystem,
|
|
160
|
+
preferences: Preferences,
|
|
161
|
+
appId: 'com.example.app',
|
|
162
|
+
serverUrl: 'https://nativeupdatebe.aoneahsan.com/api',
|
|
163
|
+
apiKey: import.meta.env.VITE_NATIVE_UPDATE_API_KEY,
|
|
164
|
+
channel: 'production',
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Confirms this boot is healthy. Without it the native layer reverts the
|
|
168
|
+
// bundle after two cold starts.
|
|
169
|
+
await NativeUpdate.notifyAppReady();
|
|
170
|
+
|
|
171
|
+
const result = await NativeUpdate.sync();
|
|
172
|
+
if (result.status === 'UPDATE_INSTALLED') {
|
|
173
|
+
await NativeUpdate.reload();
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
<a id="usage"></a>
|
|
178
|
+
## 🛠️ Usage [#](#usage)
|
|
179
|
+
|
|
180
|
+
### Prompt before applying an update
|
|
181
|
+
|
|
182
|
+
`sync()` reports what it found; you decide whether to interrupt the user.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
const result = await NativeUpdate.sync();
|
|
186
|
+
|
|
187
|
+
if (result.status === 'UPDATE_INSTALLED') {
|
|
188
|
+
const proceed = result.mandatory || (await askTheUser(result.version));
|
|
189
|
+
if (proceed) {
|
|
190
|
+
await NativeUpdate.reload();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Download manually, with progress
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const latest = await NativeUpdate.getLatest();
|
|
199
|
+
|
|
200
|
+
if (latest.available && latest.url && latest.version && latest.checksum) {
|
|
201
|
+
const listener = await NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
202
|
+
setProgress(progress.percent);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const bundle = await NativeUpdate.download({
|
|
206
|
+
url: latest.url,
|
|
207
|
+
version: latest.version,
|
|
208
|
+
checksum: latest.checksum,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
await listener.remove();
|
|
212
|
+
await NativeUpdate.set(bundle);
|
|
213
|
+
await NativeUpdate.reload();
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Handle a store update
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
const info = await NativeUpdate.getAppUpdateInfo();
|
|
221
|
+
|
|
222
|
+
if (info.updateAvailable) {
|
|
223
|
+
if (info.immediateUpdateAllowed) {
|
|
224
|
+
await NativeUpdate.performImmediateUpdate();
|
|
225
|
+
} else if (info.flexibleUpdateAllowed) {
|
|
226
|
+
await NativeUpdate.startFlexibleUpdate();
|
|
227
|
+
} else {
|
|
228
|
+
await NativeUpdate.openAppStore();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Request a review
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const { allowed } = await NativeUpdate.canRequestReview();
|
|
237
|
+
|
|
238
|
+
if (allowed) {
|
|
239
|
+
await NativeUpdate.requestReview();
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Ask after something went well for the user, never on launch. The platforms cap how often the dialog appears
|
|
244
|
+
and silently ignore extra requests.
|
|
245
|
+
|
|
246
|
+
<a id="configuration"></a>
|
|
247
|
+
## ⚙️ Configuration [#](#configuration)
|
|
248
|
+
|
|
249
|
+
Passed to `initialize()`. The complete set is in the
|
|
250
|
+
[configuration reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/config).
|
|
251
|
+
|
|
252
|
+
| Option | Type | Default | What it does |
|
|
253
|
+
|---|---|---|---|
|
|
254
|
+
| `filesystem` | `Filesystem` | — | the `@capacitor/filesystem` instance used to store bundles |
|
|
255
|
+
| `preferences` | `Preferences` | — | the `@capacitor/preferences` instance used to record bundle state |
|
|
256
|
+
| `appId` | `string` | — | identifies your app to the update server |
|
|
257
|
+
| `serverUrl` | `string` | — | base URL of the backend; the plugin appends `/v1/updates/check` |
|
|
258
|
+
| `apiKey` | `string` | — | sent as `X-API-Key`. Not persisted — pass it on every `initialize()` |
|
|
259
|
+
| `channel` | `string` | `'production'` | which release channel this install follows |
|
|
260
|
+
| `autoCheck` | `boolean` | `false` | check for updates without an explicit `sync()` |
|
|
261
|
+
| `autoUpdate` | `boolean` | `false` | apply what it finds without asking |
|
|
262
|
+
| `publicKey` | `string` | — | PEM public key used to verify bundle signatures |
|
|
263
|
+
| `enableSignatureValidation` | `boolean` | `true` | reject a bundle whose signature does not verify |
|
|
264
|
+
| `requireSignature` | `boolean` | — | reject a bundle that carries no signature at all |
|
|
265
|
+
| `maxBundleSize` | `number` | `104857600` | refuse a download larger than this, in bytes |
|
|
266
|
+
| `downloadTimeout` | `number` | `30000` | per-download timeout in milliseconds |
|
|
267
|
+
| `retryAttempts` | `number` | `3` | download retries before giving up |
|
|
268
|
+
| `retryDelay` | `number` | `1000` | milliseconds between retries |
|
|
269
|
+
| `checkInterval` | `number` | — | milliseconds between automatic checks when `autoCheck` is on |
|
|
270
|
+
| `allowedHosts` | `string[]` | — | restrict downloads to these hosts |
|
|
271
|
+
| `enableLogging` | `boolean` | `false` | verbose plugin logging |
|
|
272
|
+
|
|
273
|
+
<a id="api-reference"></a>
|
|
274
|
+
## 🔧 API Reference [#](#api-reference)
|
|
275
|
+
|
|
276
|
+
An index. Signatures and behaviour are documented per method on the docs site.
|
|
277
|
+
|
|
278
|
+
| Area | Methods | Docs |
|
|
279
|
+
|---|---|---|
|
|
280
|
+
| Lifecycle | `initialize` · `isInitialized` · `configure` · `reset` · `cleanup` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/lifecycle) |
|
|
281
|
+
| Live update | `sync` · `getLatest` · `download` · `set` · `reload` · `current` · `list` · `delete` · `notifyAppReady` · `setChannel` · `validateUpdate` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/methods) |
|
|
282
|
+
| Download control | `checkForUpdate` · `downloadUpdate` · `applyUpdate` · `cancelDownload` · `cancelAllDownloads` · `isDownloading` · `getActiveDownloadCount` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/methods) |
|
|
283
|
+
| App update | `getAppUpdateInfo` · `performImmediateUpdate` · `startFlexibleUpdate` · `completeFlexibleUpdate` · `openAppStore` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/app-update/methods) |
|
|
284
|
+
| App review | `requestReview` · `canRequestReview` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/app-review/methods) |
|
|
285
|
+
| Background | `enableBackgroundUpdates` · `disableBackgroundUpdates` · `getBackgroundUpdateStatus` · `scheduleBackgroundCheck` · `triggerBackgroundCheck` · `setNotificationPreferences` · `getNotificationPermissions` · `requestNotificationPermissions` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/background-update/methods) |
|
|
286
|
+
| Security | `getSecurityInfo` · `getAppIdentity` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/overview) |
|
|
287
|
+
| Events | `addListener` · `removeAllListeners` | [→](https://nativeupdate-docs.aoneahsan.com/reference/sdk/live-update/events) |
|
|
288
|
+
|
|
289
|
+
`setUpdateUrl()` is deprecated and does nothing. The server URL is fixed at `initialize()` so a compromised
|
|
290
|
+
WebView cannot repoint updates at another host; call `initialize()` again to switch servers.
|
|
291
|
+
|
|
292
|
+
<a id="types"></a>
|
|
293
|
+
## 🧩 Types [#](#types)
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
import type {
|
|
297
|
+
PluginInitConfig,
|
|
298
|
+
SyncResult,
|
|
299
|
+
BundleInfo,
|
|
300
|
+
LatestVersion,
|
|
301
|
+
DownloadOptions,
|
|
302
|
+
DownloadProgressEvent,
|
|
303
|
+
AppUpdateInfo,
|
|
304
|
+
ReviewResult,
|
|
305
|
+
CanRequestReviewResult,
|
|
306
|
+
} from 'native-update';
|
|
307
|
+
|
|
308
|
+
import { SyncStatus, BundleStatus, UpdateErrorCode } from 'native-update';
|
|
309
|
+
|
|
310
|
+
const result: SyncResult = {
|
|
311
|
+
status: SyncStatus.UPDATE_INSTALLED, // UP_TO_DATE | UPDATE_AVAILABLE | UPDATE_INSTALLED | ERROR
|
|
312
|
+
version: '1.2.0',
|
|
313
|
+
mandatory: false,
|
|
314
|
+
};
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Enums are real runtime values rather than type-only aliases, so they survive the build and can be compared at
|
|
318
|
+
runtime. The full type surface is exported from the package root.
|
|
319
|
+
|
|
320
|
+
<a id="command-line"></a>
|
|
321
|
+
## 💻 Command Line [#](#command-line)
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
npx native-update <command> [options]
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
| Command | What it does |
|
|
328
|
+
|---|---|
|
|
329
|
+
| `init` | scaffold plugin configuration into an existing project |
|
|
330
|
+
| `bundle create <webDir>` | zip a build directory into a bundle and compute its checksum |
|
|
331
|
+
| `bundle sign <bundle>` | sign a bundle with a private key |
|
|
332
|
+
| `bundle verify <bundle>` | verify a bundle's signature against a public key |
|
|
333
|
+
| `keys generate` | generate an RSA or EC signing key pair |
|
|
334
|
+
| `backend create <type>` | scaffold an `express`, `firebase` or `vercel` backend |
|
|
335
|
+
| `server start` | run a local update server for testing |
|
|
336
|
+
| `monitor` | watch deployments against a backend |
|
|
337
|
+
| `deploy <dirOrZip>` | upload a bundle to the hosted backend and publish it |
|
|
338
|
+
| `token info` | show what an access token is and which apps it can manage |
|
|
339
|
+
| `apps …` | create, show, update and delete apps; manage API keys, signing keys and keystore backups |
|
|
340
|
+
| `builds …` | list, promote, roll out, inspect and delete builds |
|
|
341
|
+
| `jobs status <jobId>` | poll a queued upload job |
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
npx native-update keys generate --type rsa --size 4096
|
|
345
|
+
npx native-update bundle create ./dist --version 1.2.0 --channel production
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Deploying to the hosted backend needs an access token in `NATIVE_UPDATE_TOKEN` — never a flag, which lands in
|
|
349
|
+
shell history and CI logs.
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
export NATIVE_UPDATE_TOKEN=nu_pat_…
|
|
353
|
+
|
|
354
|
+
# Zips ./dist, uploads it, and blocks until the release is live.
|
|
355
|
+
# Exits non-zero on failure, so a broken release fails the build.
|
|
356
|
+
npx native-update deploy ./dist --app com.example.app --version 1.2.0 --wait
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
| Flag | Default | What it does |
|
|
360
|
+
|---|---|---|
|
|
361
|
+
| `--app <idOrNumericId>` | — | required; the app to deploy to |
|
|
362
|
+
| `--version <semver>` | `package.json` version | the bundle version, which must be higher than the current one |
|
|
363
|
+
| `--channel <name>` | `production` | release channel |
|
|
364
|
+
| `--rollout <percent>` | — | release to a percentage of devices |
|
|
365
|
+
| `--wait` | `false` | block until the queued upload finishes — **use this in CI** |
|
|
366
|
+
|
|
367
|
+
Full reference: [CLI docs](https://nativeupdate-docs.aoneahsan.com/reference/cli/overview).
|
|
368
|
+
|
|
369
|
+
<a id="examples"></a>
|
|
370
|
+
## 🧪 Examples [#](#examples)
|
|
371
|
+
|
|
372
|
+
| Goal | Walkthrough |
|
|
373
|
+
|---|---|
|
|
374
|
+
| Ship a first OTA update end to end | [→](https://nativeupdate-docs.aoneahsan.com/tutorials/first-ota-update) |
|
|
375
|
+
| Stand up a backend, then wire the app to it | [→](https://nativeupdate-docs.aoneahsan.com/tutorials/backend-first-walkthrough) |
|
|
376
|
+
| Test bundles locally before publishing | [→](https://nativeupdate-docs.aoneahsan.com/how-to/test-bundles-locally) |
|
|
377
|
+
| Roll a bad bundle back | [→](https://nativeupdate-docs.aoneahsan.com/how-to/roll-back-bundle) |
|
|
378
|
+
| Deploy from GitHub Actions | [→](https://nativeupdate-docs.aoneahsan.com/how-to/ci-cd-github-actions) |
|
|
379
|
+
| Migrate from CodePush | [→](https://nativeupdate-docs.aoneahsan.com/how-to/migrate-from-codepush) |
|
|
380
|
+
|
|
381
|
+
<a id="advanced-features"></a>
|
|
382
|
+
## 🎛️ Advanced Features [#](#advanced-features)
|
|
383
|
+
|
|
384
|
+
- **Public Management API** — apps, API keys, signing keys, keystore backups, uploads, promotion and
|
|
385
|
+
rollouts over HTTP, so CI or a coding agent can run an app's whole lifecycle.
|
|
386
|
+
[Overview](https://nativeupdate-docs.aoneahsan.com/public-api/overview) ·
|
|
387
|
+
[Endpoints](https://nativeupdate-docs.aoneahsan.com/public-api/endpoints)
|
|
388
|
+
- **Queued uploads** — an upload answers `202` with a job id, and the build stays invisible to devices until
|
|
389
|
+
processing finishes, so a half-uploaded build can never reach a user.
|
|
390
|
+
[Queued jobs](https://nativeupdate-docs.aoneahsan.com/public-api/async-jobs)
|
|
391
|
+
- **API key restrictions** — lock a key to your web origins, your Android package plus signing-certificate
|
|
392
|
+
fingerprints, or your iOS bundle id, so it can ship inside your app.
|
|
393
|
+
[How to](https://nativeupdate-docs.aoneahsan.com/how-to/restrict-api-keys)
|
|
394
|
+
- **Bundle signing** — sign bundles with your own key; the plugin verifies the signature before activation
|
|
395
|
+
and again at boot.
|
|
396
|
+
[Integrity and signing](https://nativeupdate-docs.aoneahsan.com/concepts/bundle-integrity-and-signing)
|
|
397
|
+
- **Certificate pinning** — pin the update host's certificate on iOS and Android.
|
|
398
|
+
[Reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/certificate-pinning)
|
|
399
|
+
- **Self-hosting** — run the Laravel + Nova backend yourself on any PHP 8.3+ host.
|
|
400
|
+
[Self-host guide](https://nativeupdate-docs.aoneahsan.com/backend/laravel-nova-self-host)
|
|
401
|
+
|
|
402
|
+
<a id="recovery-troubleshooting"></a>
|
|
403
|
+
## 🚑 Recovery & Troubleshooting [#](#recovery-troubleshooting)
|
|
404
|
+
|
|
405
|
+
| Symptom | Cause | Fix |
|
|
406
|
+
|---|---|---|
|
|
407
|
+
| `getDefaultProguardFile('proguard-android.txt') is no longer supported` while building your Android release | The plugin's `android/build.gradle` names a default file the current Android Gradle Plugin removed. Present in 3.4.1 and 3.3.1 | Patch the installed package's `android/build.gradle` to use `proguard-android-optimize.txt` — Yarn's `patch:` protocol handles this — until a release fixes it |
|
|
408
|
+
| Every update reverts a few minutes after it applies | `notifyAppReady()` is never called, so the native layer treats each boot as failed | Call `notifyAppReady()` once per successful boot, right after `initialize()` |
|
|
409
|
+
| `require('native-update')` returns `{}` | Fixed in 3.4.1. Earlier versions emitted the CommonJS artifact with a `.js` extension inside a `"type": "module"` package, so Node loaded it as ESM | Upgrade to `3.4.1` or later |
|
|
410
|
+
| Updates work on web, nothing happens on device | `npx cap sync` was not run after installing | Run `npx cap sync` and rebuild the native app |
|
|
411
|
+
| `initialize()` rejects, or downloads fail with an auth error | The API key is missing, wrong, or restricted to clients that do not include this one | Check the key and its restrictions in the dashboard |
|
|
412
|
+
| The server returns a bundle but it never installs | Checksum or signature verification failed, so the bundle was rejected before activation | Re-create and re-sign the bundle; confirm `publicKey` matches the signing key |
|
|
413
|
+
| A device never receives a release | The build is still processing, paused, or outside the rollout percentage | Check the build's status and rollout in the dashboard or with `builds status` |
|
|
414
|
+
|
|
415
|
+
More: [troubleshooting guide](https://nativeupdate-docs.aoneahsan.com/how-to/troubleshooting) ·
|
|
416
|
+
[error codes](https://nativeupdate-docs.aoneahsan.com/reference/sdk/security/error-codes).
|
|
417
|
+
|
|
418
|
+
<a id="limitations"></a>
|
|
419
|
+
## 🚧 Limitations [#](#limitations)
|
|
420
|
+
|
|
421
|
+
- **Android release builds currently fail to configure.** `android/build.gradle` references a ProGuard
|
|
422
|
+
default file the current Android Gradle Plugin removed, so a consuming app's release build stops while
|
|
423
|
+
evaluating this plugin. A workaround is in
|
|
424
|
+
[Recovery & Troubleshooting](#recovery-troubleshooting); a fix is pending a release.
|
|
425
|
+
- **OTA replaces the web layer only.** Anything that changes native code, permissions or the manifest still
|
|
426
|
+
needs a store release.
|
|
427
|
+
- **You supply the backend.** This package does not host your bundles. Use the hosted dashboard, self-host
|
|
428
|
+
the reference backend, or implement the HTTP contract.
|
|
429
|
+
- **Web is not a deployment target for the native flows.** Store-update and review calls resolve without
|
|
430
|
+
doing anything on web, and certificate pinning is unavailable there because browsers do not expose
|
|
431
|
+
certificate details to JavaScript. Storage capacity on web is a fixed default, not a measurement.
|
|
432
|
+
- **Mobile key restrictions are client-attested, not cryptographic attestation.** The plugin sends the
|
|
433
|
+
Android package and signing-certificate fingerprints, or the iOS bundle id, as headers — the same trust
|
|
434
|
+
model as a restricted Google Maps key. They stop casual key reuse; they are not proof of origin. Web
|
|
435
|
+
origin restrictions are stronger, because the browser sets `Origin` and page JavaScript cannot forge it.
|
|
436
|
+
Layer Play Integrity or App Attest yourself if you need hard attestation.
|
|
437
|
+
- **Apps built on versions older than 3.2.0 send no identity headers**, so an Android or iOS key
|
|
438
|
+
restriction blocks them until the app is rebuilt.
|
|
439
|
+
- **The iOS team id is not sent.** The dashboard accepts `team_id`, but the plugin does not send
|
|
440
|
+
`X-Ios-Team-Id`; set it only if your own fetch does.
|
|
441
|
+
- **`engines` requires Node `>=24.16.0`.** Installers that enforce `engines` refuse an older runtime. This
|
|
442
|
+
affects your build machine, not your users' devices.
|
|
443
|
+
- **Store policy is your responsibility.** Both platforms permit updating interpreted code within limits;
|
|
444
|
+
shipping something that changes what your app does is your call to defend.
|
|
445
|
+
|
|
446
|
+
<a id="faq"></a>
|
|
447
|
+
## ❓ FAQ [#](#faq)
|
|
448
|
+
|
|
449
|
+
**Do I have to use the hosted backend?**
|
|
450
|
+
No. The [HTTP contract](https://nativeupdate-docs.aoneahsan.com/backend/api-contract) is published, the
|
|
451
|
+
Laravel + Nova backend is self-hostable, and the CLI can scaffold an Express, Firebase or Vercel server.
|
|
452
|
+
|
|
453
|
+
**Does `require()` work, or is this ESM-only?**
|
|
454
|
+
Both. The package publishes an ESM build and a real CommonJS build with matching type declarations. Versions
|
|
455
|
+
before 3.4.1 had a broken CommonJS entry point — upgrade if `require()` returned an empty object.
|
|
456
|
+
|
|
457
|
+
**Will an OTA update get my app rejected?**
|
|
458
|
+
Updating interpreted code is permitted by both stores within their policies. Changing what your app
|
|
459
|
+
fundamentally does, or using OTA to bypass review for native functionality, is not. Read the policies and
|
|
460
|
+
stay inside them.
|
|
461
|
+
|
|
462
|
+
**What happens if an update breaks the app?**
|
|
463
|
+
It is reverted. A newly activated bundle stays pending until `notifyAppReady()` confirms a healthy boot; two
|
|
464
|
+
cold starts without that confirmation trigger an automatic rollback to the previous bundle.
|
|
465
|
+
|
|
466
|
+
**Can I ship the API key inside my app?**
|
|
467
|
+
Yes, once you restrict it. An unrestricted key works from anywhere and belongs on a server. See
|
|
468
|
+
[restricting API keys](https://nativeupdate-docs.aoneahsan.com/how-to/restrict-api-keys), and note the
|
|
469
|
+
attestation limits in [Limitations](#limitations).
|
|
470
|
+
|
|
471
|
+
**Is the source public?**
|
|
472
|
+
No. The repository is private; the published package, its type declarations and the documentation site are
|
|
473
|
+
the public surface.
|
|
474
|
+
|
|
475
|
+
<a id="documentation"></a>
|
|
476
|
+
## 📚 Documentation [#](#documentation)
|
|
477
|
+
|
|
478
|
+
| Document | Read it when |
|
|
479
|
+
|---|---|
|
|
480
|
+
| [Introduction](https://nativeupdate-docs.aoneahsan.com/intro) | deciding whether this fits your app |
|
|
481
|
+
| [Installation](https://nativeupdate-docs.aoneahsan.com/getting-started/installation) | setting the plugin up for the first time |
|
|
482
|
+
| [Quick start](https://nativeupdate-docs.aoneahsan.com/getting-started/quick-start) | you want a working update within the hour |
|
|
483
|
+
| [How OTA updates work](https://nativeupdate-docs.aoneahsan.com/concepts/how-ota-updates-work) | you need the mental model before designing a flow |
|
|
484
|
+
| [Security model](https://nativeupdate-docs.aoneahsan.com/concepts/security-model) | reviewing this for production |
|
|
485
|
+
| [SDK reference](https://nativeupdate-docs.aoneahsan.com/reference/sdk/core/config) | you need an exact signature or option |
|
|
486
|
+
| [CLI reference](https://nativeupdate-docs.aoneahsan.com/reference/cli/overview) | scripting releases |
|
|
487
|
+
| [Backend overview](https://nativeupdate-docs.aoneahsan.com/backend/overview) | choosing or building an update server |
|
|
488
|
+
| [Public Management API](https://nativeupdate-docs.aoneahsan.com/public-api/overview) | automating releases from CI |
|
|
489
|
+
| [Platform notes](https://nativeupdate-docs.aoneahsan.com/platforms/android) | something behaves differently on one platform |
|
|
490
|
+
| [AI integration guide](https://nativeupdate-docs.aoneahsan.com/ai-integration) | a coding agent is implementing against this |
|
|
491
|
+
|
|
492
|
+
Machine-readable sources for agents: the
|
|
493
|
+
[OpenAPI 3.1 spec](https://nativeupdate-docs.aoneahsan.com/openapi/public-api.json) and a raw-Markdown mirror
|
|
494
|
+
indexed at [`/raw/manifest.json`](https://nativeupdate-docs.aoneahsan.com/raw/manifest.json).
|
|
495
|
+
|
|
496
|
+
<a id="changelog"></a>
|
|
497
|
+
## 🔄 Changelog [#](#changelog)
|
|
498
|
+
|
|
499
|
+
Latest release: **`3.4.2`** — fixed `require('native-update')` returning an empty object for every CommonJS
|
|
500
|
+
consumer, pointed `repository` at the real git remote, and stopped internal agent-instruction files shipping
|
|
501
|
+
in the tarball.
|
|
502
|
+
|
|
503
|
+
Full history ships inside the package at `docs/CHANGELOG.md`, so it always matches the version you
|
|
504
|
+
installed. It is also published as the
|
|
505
|
+
[online changelog](https://nativeupdate-docs.aoneahsan.com/changelog).
|
|
506
|
+
|
|
507
|
+
<a id="contributing"></a>
|
|
508
|
+
## 🤝 Contributing [#](#contributing)
|
|
509
|
+
|
|
510
|
+
The source repository is private, so there is no fork-and-pull-request path. Bug reports, reproductions and
|
|
511
|
+
feature proposals are genuinely wanted and are the most useful contribution you can make — send them through
|
|
512
|
+
the [contact page](https://nativeupdate.aoneahsan.com/contact). Include the package version, the platform,
|
|
513
|
+
and the smallest reproduction you can manage.
|
|
514
|
+
|
|
515
|
+
<a id="support"></a>
|
|
516
|
+
## 💬 Support [#](#support)
|
|
517
|
+
|
|
518
|
+
Questions and bugs: [nativeupdate.aoneahsan.com/contact](https://nativeupdate.aoneahsan.com/contact).
|
|
519
|
+
|
|
520
|
+
If this package saves you time, you can support its maintenance at
|
|
521
|
+
[aoneahsan.com/payment](https://aoneahsan.com/payment?project-id=native-update&project-identifier=native-update).
|
|
522
|
+
|
|
523
|
+
<a id="license"></a>
|
|
524
|
+
## 📄 License [#](#license)
|
|
525
|
+
|
|
526
|
+
MIT © Ahsan Mahmood. The full text ships in the package as `LICENSE`.
|
|
527
|
+
|
|
528
|
+
<a id="author"></a>
|
|
529
|
+
## 👤 Author [#](#author)
|
|
530
|
+
|
|
531
|
+
**Ahsan Mahmood** — [aoneahsan.com](https://aoneahsan.com) ·
|
|
532
|
+
[LinkedIn](https://linkedin.com/in/aoneahsan) · [aoneahsan@gmail.com](mailto:aoneahsan@gmail.com)
|
|
533
|
+
|
|
534
|
+
<a id="links"></a>
|
|
535
|
+
## 🔗 Links [#](#links)
|
|
536
|
+
|
|
537
|
+
| | |
|
|
538
|
+
|---|---|
|
|
539
|
+
| Documentation | https://nativeupdate-docs.aoneahsan.com |
|
|
540
|
+
| npm | https://www.npmjs.com/package/native-update |
|
|
541
|
+
| Dashboard and website | https://nativeupdate.aoneahsan.com |
|
|
542
|
+
| Changelog | https://nativeupdate-docs.aoneahsan.com/changelog |
|
|
543
|
+
| AI integration guide | https://nativeupdate-docs.aoneahsan.com/ai-integration |
|
|
544
|
+
| OpenAPI spec | https://nativeupdate-docs.aoneahsan.com/openapi/public-api.json |
|
|
545
|
+
| Report an issue | https://nativeupdate.aoneahsan.com/contact |
|
|
546
|
+
| Support the project | https://aoneahsan.com/payment?project-id=native-update&project-identifier=native-update |
|
|
547
|
+
|
|
548
|
+
<a id="keywords"></a>
|
|
549
|
+
## 🏷️ Keywords [#](#keywords)
|
|
550
|
+
|
|
551
|
+
*capacitor · plugin · native · app-updates · native-updates · ota · live-updates · hot-reload · app-store · google-play · in-app-updates · app-reviews · ios · android · hybrid*
|
package/android/build.gradle
CHANGED
|
@@ -42,7 +42,12 @@ android {
|
|
|
42
42
|
buildTypes {
|
|
43
43
|
release {
|
|
44
44
|
minifyEnabled false
|
|
45
|
-
|
|
45
|
+
// MUST be the -optimize variant. The current Android Gradle Plugin hard-rejects
|
|
46
|
+
// 'proguard-android.txt' (it bundles -dontoptimize), and the call is evaluated at
|
|
47
|
+
// CONFIGURATION time - so a consuming app's release build fails at evaluation of
|
|
48
|
+
// :native-update even with minifyEnabled false. Every other Capacitor plugin already
|
|
49
|
+
// uses the -optimize file. See docs/REPORTED-ISSUES.md ISSUE-01.
|
|
50
|
+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|