@capgo/capacitor-updater 7.38.0 → 7.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
  s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
14
  s.ios.deployment_target = '14.0'
15
15
  s.dependency 'Capacitor'
16
- s.dependency 'SSZipArchive', '2.4.3'
16
+ s.dependency 'ZIPFoundation', '~> 0.9'
17
17
  s.dependency 'Alamofire', '5.10.2'
18
18
  s.dependency 'Version', '0.8.0'
19
19
  # We cannot update to latest because it not published anymore in cocoa https://github.com/attaswift/BigInt/issues/94
package/Package.swift CHANGED
@@ -12,7 +12,7 @@ let package = Package(
12
12
  dependencies: [
13
13
  .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0"),
14
14
  .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.10.2")),
15
- .package(url: "https://github.com/ZipArchive/ZipArchive.git", exact: "2.4.3"),
15
+ .package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.0"),
16
16
  .package(url: "https://github.com/mrackwitz/Version.git", exact: "0.8.0"),
17
17
  .package(url: "https://github.com/attaswift/BigInt.git", from: "5.7.0")
18
18
  ],
@@ -22,7 +22,7 @@ let package = Package(
22
22
  dependencies: [
23
23
  .product(name: "Capacitor", package: "capacitor-swift-pm"),
24
24
  .product(name: "Cordova", package: "capacitor-swift-pm"),
25
- .product(name: "ZipArchive", package: "ZipArchive"),
25
+ .product(name: "ZIPFoundation", package: "ZIPFoundation"),
26
26
  .product(name: "Alamofire", package: "Alamofire"),
27
27
  .product(name: "Version", package: "Version"),
28
28
  .product(name: "BigInt", package: "BigInt")
package/README.md CHANGED
@@ -68,6 +68,12 @@ Join the [discord](https://discord.gg/VnYRvBfgA6) to get help.
68
68
 
69
69
  ## Migration to v8
70
70
 
71
+ This major version is here to follow Capacitor major version 8
72
+
73
+ First follow the migration guide of Capacitor:
74
+
75
+ [https://capacitorjs.com/docs/updating/8-0](https://capacitorjs.com/docs/updating/8-0/)
76
+
71
77
  ## Migration to v7.34
72
78
 
73
79
  - **Channel storage change**: `setChannel()` now stores channel assignments locally on the device instead of in the cloud. This provides better offline support and reduces backend load.
@@ -78,18 +84,18 @@ Join the [discord](https://discord.gg/VnYRvBfgA6) to get help.
78
84
 
79
85
  ## Migration to v7
80
86
 
81
- The min version of IOS is now 15.5 instead of 15 as Capacitor 8 requirement.
82
- This is due to bump of ZipArchive to latest, a key dependency of this project is the zlib library. zlib before version 1.2.12 allows memory corruption when deflating (i.e., when compressing) if the input has many distant matches according to [CVE-2018-25032](https://nvd.nist.gov/vuln/detail/cve-2018-25032).
83
- zlib is a native library so we need to bump the minimum iOS version to 15.5 as ZipArchive did the same in their latest versions.
87
+ The minimum iOS version is now **15.0** to match Capacitor 7/8 requirements.
88
+
89
+ Starting from v8, the plugin uses [ZIPFoundation](https://github.com/weichsel/ZIPFoundation) instead of SSZipArchive/ZipArchive for ZIP extraction. ZIPFoundation uses Apple's native `libcompression` framework, which removes the previous zlib dependency and its associated security constraints.
84
90
 
85
91
  ## Compatibility
86
92
 
87
93
  | Plugin version | Capacitor compatibility | Maintained |
88
94
  | -------------- | ----------------------- | ----------------- |
89
- | v8.\*.\* | v8.\*.\* | Beta |
95
+ | v8.\*.\* | v8.\*.\* | |
90
96
  | v7.\*.\* | v7.\*.\* | ✅ |
91
97
  | v6.\*.\* | v6.\*.\* | ✅ |
92
- | v5.\*.\* | v5.\*.\* | ⚠️ Deprecated |
98
+ | v5.\*.\* | v5.\*.\* | |
93
99
  | v4.\*.\* | v4.\*.\* | ⚠️ Deprecated |
94
100
  | v3.\*.\* | v3.\*.\* | ⚠️ Deprecated |
95
101
  | > 7 | v4.\*.\* | ⚠️ Deprecated, our CI got crazy and bumped too much version |
@@ -251,142 +257,7 @@ Capacitor Updater works by unzipping a compiled app bundle to the native device
251
257
  <docgen-config>
252
258
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
253
259
 
254
- CapacitorUpdater can be configured with these options:
255
-
256
- | Prop | Type | Description | Default | Since |
257
- | ----------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
258
- | **`appReadyTimeout`** | <code>number</code> | Configure the number of milliseconds the native plugin should wait before considering an update 'failed'. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | |
259
- | **`responseTimeout`** | <code>number</code> | Configure the number of seconds the native plugin should wait before considering API timeout. Only available for Android and iOS. | <code>20 // (20 second)</code> | |
260
- | **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | <code>true</code> | |
261
- | **`autoDeletePrevious`** | <code>boolean</code> | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS. | <code>true</code> | |
262
- | **`autoUpdate`** | <code>boolean</code> | Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS. | <code>true</code> | |
263
- | **`resetWhenUpdate`** | <code>boolean</code> | Automatically delete previous downloaded bundles when a newer native app bundle is installed to the device. Setting this to false can broke the auto update flow if the user download from the store a native app bundle that is older than the current downloaded bundle. Upload will be prevented by channel setting downgrade_under_native. Only available for Android and iOS. | <code>true</code> | |
264
- | **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS. | <code>https://plugin.capgo.app/updates</code> | |
265
- | **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS. | <code>https://plugin.capgo.app/channel_self</code> | |
266
- | **`statsUrl`** | <code>string</code> | Configure the URL / endpoint to which update statistics are sent. Only available for Android and iOS. Set to "" to disable stats reporting. | <code>https://plugin.capgo.app/stats</code> | |
267
- | **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS. | <code>undefined</code> | 6.2.0 |
268
- | **`version`** | <code>string</code> | Configure the current version of the app. This will be used for the first update request. If not set, the plugin will get the version from the native code. Only available for Android and iOS. | <code>undefined</code> | 4.17.48 |
269
- | **`directUpdate`** | <code>boolean \| 'always' \| 'atInstall' \| 'onLaunch'</code> | Configure when the plugin should direct install updates. Only for autoUpdate mode. Works well for apps less than 10MB and with uploads done using --partial flag. Zip or apps more than 10MB will be relatively slow for users to update. - false: Never do direct updates (use default behavior: download at start, set when backgrounded) - atInstall: Direct update only when app is installed, updated from store, otherwise act as directUpdate = false - onLaunch: Direct update only on app installed, updated from store or after app kill, otherwise act as directUpdate = false - always: Direct update in all previous cases (app installed, updated from store, after app kill or app resume), never act as directUpdate = false - true: (deprecated) Same as "always" for backward compatibility Only available for Android and iOS. | <code>false</code> | 5.1.0 |
270
- | **`autoSplashscreen`** | <code>boolean</code> | Automatically handle splashscreen hiding when using directUpdate. When enabled, the plugin will automatically hide the splashscreen after updates are applied or when no update is needed. This removes the need to manually listen for appReady events and call SplashScreen.hide(). Only works when directUpdate is set to "atInstall", "always", "onLaunch", or true. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Requires autoUpdate and directUpdate to be enabled. Only available for Android and iOS. | <code>false</code> | 7.6.0 |
271
- | **`autoSplashscreenLoader`** | <code>boolean</code> | Display a native loading indicator on top of the splashscreen while automatic direct updates are running. Only takes effect when {@link autoSplashscreen} is enabled. Requires the @capacitor/splash-screen plugin to be installed and configured with launchAutoHide: false. Only available for Android and iOS. | <code>false</code> | 7.19.0 |
272
- | **`autoSplashscreenTimeout`** | <code>number</code> | Automatically hide the splashscreen after the specified number of milliseconds when using automatic direct updates. If the timeout elapses, the update continues to download in the background while the splashscreen is dismissed. Set to `0` (zero) to disable the timeout. When the timeout fires, the direct update flow is skipped and the downloaded bundle is installed on the next background/launch. Requires {@link autoSplashscreen} to be enabled. Only available for Android and iOS. | <code>10000 // (10 seconds)</code> | 7.19.0 |
273
- | **`periodCheckDelay`** | <code>number</code> | Configure the delay period for period update check. the unit is in seconds. Only available for Android and iOS. Cannot be less than 600 seconds (10 minutes). | <code>0 (disabled)</code> | |
274
- | **`localS3`** | <code>boolean</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
275
- | **`localHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
276
- | **`localWebHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
277
- | **`localSupa`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server. | <code>undefined</code> | 4.17.48 |
278
- | **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing. | <code>undefined</code> | 4.17.48 |
279
- | **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing. | <code>undefined</code> | 6.3.3 |
280
- | **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing. | <code>undefined</code> | 6.3.3 |
281
- | **`allowModifyUrl`** | <code>boolean</code> | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side. | <code>false</code> | 5.4.0 |
282
- | **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side. | <code>false</code> | 7.14.0 |
283
- | **`allowManualBundleError`** | <code>boolean</code> | Allow marking bundles as errored from JavaScript while using manual update flows. When enabled, {@link CapacitorUpdaterPlugin.setBundleError} can change a bundle status to `error`. | <code>false</code> | 7.20.0 |
284
- | **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS. | <code>false (will be true by default in a future major release v8.x.x)</code> | 7.17.3 |
285
- | **`persistModifyUrl`** | <code>boolean</code> | Persist the updateUrl, statsUrl and channelUrl set through {@link CapacitorUpdaterPlugin.setUpdateUrl}, {@link CapacitorUpdaterPlugin.setStatsUrl} and {@link CapacitorUpdaterPlugin.setChannelUrl} across app restarts. Only available for Android and iOS. | <code>false</code> | 7.20.0 |
286
- | **`allowSetDefaultChannel`** | <code>boolean</code> | Allow or disallow the {@link CapacitorUpdaterPlugin.setChannel} method to modify the defaultChannel. When set to `false`, calling `setChannel()` will return an error with code `disabled_by_config`. | <code>true</code> | 7.34.0 |
287
- | **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. This requires the channel to allow devices to self dissociate/associate in the channel settings. https://capgo.app/docs/public-api/channels/#channel-configuration-options | <code>undefined</code> | 5.5.0 |
288
- | **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
289
- | **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
290
- | **`disableJSLogging`** | <code>boolean</code> | Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done | <code>false</code> | 7.3.0 |
291
- | **`shakeMenu`** | <code>boolean</code> | Enable shake gesture to show update menu for debugging/testing purposes | <code>false</code> | 7.5.0 |
292
-
293
- ### Examples
294
-
295
- In `capacitor.config.json`:
296
260
 
297
- ```json
298
- {
299
- "plugins": {
300
- "CapacitorUpdater": {
301
- "appReadyTimeout": 1000 // (1 second, minimum 1000),
302
- "responseTimeout": 10 // (10 second),
303
- "autoDeleteFailed": false,
304
- "autoDeletePrevious": false,
305
- "autoUpdate": false,
306
- "resetWhenUpdate": false,
307
- "updateUrl": https://example.com/api/auto_update,
308
- "channelUrl": https://example.com/api/channel,
309
- "statsUrl": https://example.com/api/stats,
310
- "publicKey": undefined,
311
- "version": undefined,
312
- "directUpdate": undefined,
313
- "autoSplashscreen": undefined,
314
- "autoSplashscreenLoader": undefined,
315
- "autoSplashscreenTimeout": undefined,
316
- "periodCheckDelay": 3600 (1 hour),
317
- "localS3": undefined,
318
- "localHost": undefined,
319
- "localWebHost": undefined,
320
- "localSupa": undefined,
321
- "localSupaAnon": undefined,
322
- "localApi": undefined,
323
- "localApiFiles": undefined,
324
- "allowModifyUrl": undefined,
325
- "allowModifyAppId": undefined,
326
- "allowManualBundleError": undefined,
327
- "persistCustomId": undefined,
328
- "persistModifyUrl": undefined,
329
- "allowSetDefaultChannel": undefined,
330
- "defaultChannel": undefined,
331
- "appId": undefined,
332
- "keepUrlPathAfterReload": undefined,
333
- "disableJSLogging": undefined,
334
- "shakeMenu": undefined
335
- }
336
- }
337
- }
338
- ```
339
-
340
- In `capacitor.config.ts`:
341
-
342
- ```ts
343
- /// <reference types="@capgo/capacitor-updater" />
344
-
345
- import { CapacitorConfig } from '@capacitor/cli';
346
-
347
- const config: CapacitorConfig = {
348
- plugins: {
349
- CapacitorUpdater: {
350
- appReadyTimeout: 1000 // (1 second, minimum 1000),
351
- responseTimeout: 10 // (10 second),
352
- autoDeleteFailed: false,
353
- autoDeletePrevious: false,
354
- autoUpdate: false,
355
- resetWhenUpdate: false,
356
- updateUrl: https://example.com/api/auto_update,
357
- channelUrl: https://example.com/api/channel,
358
- statsUrl: https://example.com/api/stats,
359
- publicKey: undefined,
360
- version: undefined,
361
- directUpdate: undefined,
362
- autoSplashscreen: undefined,
363
- autoSplashscreenLoader: undefined,
364
- autoSplashscreenTimeout: undefined,
365
- periodCheckDelay: 3600 (1 hour),
366
- localS3: undefined,
367
- localHost: undefined,
368
- localWebHost: undefined,
369
- localSupa: undefined,
370
- localSupaAnon: undefined,
371
- localApi: undefined,
372
- localApiFiles: undefined,
373
- allowModifyUrl: undefined,
374
- allowModifyAppId: undefined,
375
- allowManualBundleError: undefined,
376
- persistCustomId: undefined,
377
- persistModifyUrl: undefined,
378
- allowSetDefaultChannel: undefined,
379
- defaultChannel: undefined,
380
- appId: undefined,
381
- keepUrlPathAfterReload: undefined,
382
- disableJSLogging: undefined,
383
- shakeMenu: undefined,
384
- },
385
- },
386
- };
387
-
388
- export default config;
389
- ```
390
261
 
391
262
  </docgen-config>
392
263
 
@@ -432,6 +303,7 @@ export default config;
432
303
  * [`addListener('appReloaded', ...)`](#addlistenerappreloaded-)
433
304
  * [`addListener('appReady', ...)`](#addlistenerappready-)
434
305
  * [`addListener('channelPrivate', ...)`](#addlistenerchannelprivate-)
306
+ * [`addListener('onFlexibleUpdateStateChange', ...)`](#addlisteneronflexibleupdatestatechange-)
435
307
  * [`isAutoUpdateAvailable()`](#isautoupdateavailable)
436
308
  * [`getNextBundle()`](#getnextbundle)
437
309
  * [`getFailedUpdate()`](#getfailedupdate)
@@ -439,8 +311,14 @@ export default config;
439
311
  * [`isShakeMenuEnabled()`](#isshakemenuenabled)
440
312
  * [`getAppId()`](#getappid)
441
313
  * [`setAppId(...)`](#setappid)
314
+ * [`getAppUpdateInfo(...)`](#getappupdateinfo)
315
+ * [`openAppStore(...)`](#openappstore)
316
+ * [`performImmediateUpdate()`](#performimmediateupdate)
317
+ * [`startFlexibleUpdate()`](#startflexibleupdate)
318
+ * [`completeFlexibleUpdate()`](#completeflexibleupdate)
442
319
  * [Interfaces](#interfaces)
443
320
  * [Type Aliases](#type-aliases)
321
+ * [Enums](#enums)
444
322
 
445
323
  </docgen-index>
446
324
 
@@ -1444,6 +1322,43 @@ This event is useful for:
1444
1322
  --------------------
1445
1323
 
1446
1324
 
1325
+ #### addListener('onFlexibleUpdateStateChange', ...)
1326
+
1327
+ ```typescript
1328
+ addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void) => Promise<PluginListenerHandle>
1329
+ ```
1330
+
1331
+ Listen for flexible update state changes on Android.
1332
+
1333
+ This event fires during the flexible update download process, providing:
1334
+ - Download progress (bytes downloaded / total bytes)
1335
+ - Installation status changes
1336
+
1337
+ **Install status values:**
1338
+ - `UNKNOWN` (0): Unknown status
1339
+ - `PENDING` (1): Download pending
1340
+ - `DOWNLOADING` (2): Download in progress
1341
+ - `INSTALLING` (3): Installing the update
1342
+ - `INSTALLED` (4): Update installed (app restart needed)
1343
+ - `FAILED` (5): Update failed
1344
+ - `CANCELED` (6): Update was canceled
1345
+ - `DOWNLOADED` (11): Download complete, ready to install
1346
+
1347
+ When status is `DOWNLOADED`, you should prompt the user and call
1348
+ {@link completeFlexibleUpdate} to finish the installation.
1349
+
1350
+ | Param | Type |
1351
+ | ------------------ | --------------------------------------------------------------------------------------- |
1352
+ | **`eventName`** | <code>'onFlexibleUpdateStateChange'</code> |
1353
+ | **`listenerFunc`** | <code>(state: <a href="#flexibleupdatestate">FlexibleUpdateState</a>) =&gt; void</code> |
1354
+
1355
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
1356
+
1357
+ **Since:** 8.0.0
1358
+
1359
+ --------------------
1360
+
1361
+
1447
1362
  #### isAutoUpdateAvailable()
1448
1363
 
1449
1364
  ```typescript
@@ -1642,6 +1557,164 @@ app IDs, or multi-tenant configurations).
1642
1557
  --------------------
1643
1558
 
1644
1559
 
1560
+ #### getAppUpdateInfo(...)
1561
+
1562
+ ```typescript
1563
+ getAppUpdateInfo(options?: GetAppUpdateInfoOptions | undefined) => Promise<AppUpdateInfo>
1564
+ ```
1565
+
1566
+ Get information about the app's availability in the App Store or Play Store.
1567
+
1568
+ This method checks the native app stores to see if a newer version of the app
1569
+ is available for download. This is different from Capgo's OTA updates - this
1570
+ checks for native app updates that require going through the app stores.
1571
+
1572
+ **Platform differences:**
1573
+ - **Android**: Uses Play Store's In-App Updates API for accurate update information
1574
+ - **iOS**: Queries the App Store lookup API (requires country code for accurate results)
1575
+
1576
+ **Returns information about:**
1577
+ - Current installed version
1578
+ - Available version in the store (if any)
1579
+ - Whether an update is available
1580
+ - Update priority (Android only)
1581
+ - Whether immediate/flexible updates are allowed (Android only)
1582
+
1583
+ Use this to:
1584
+ - Check if users need to update from the app store
1585
+ - Show "Update Available" prompts for native updates
1586
+ - Implement version gating (require minimum native version)
1587
+ - Combine with Capgo OTA updates for a complete update strategy
1588
+
1589
+ | Param | Type | Description |
1590
+ | ------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
1591
+ | **`options`** | <code><a href="#getappupdateinfooptions">GetAppUpdateInfoOptions</a></code> | Optional {@link <a href="#getappupdateinfooptions">GetAppUpdateInfoOptions</a>} with country code for iOS. |
1592
+
1593
+ **Returns:** <code>Promise&lt;<a href="#appupdateinfo">AppUpdateInfo</a>&gt;</code>
1594
+
1595
+ **Since:** 8.0.0
1596
+
1597
+ --------------------
1598
+
1599
+
1600
+ #### openAppStore(...)
1601
+
1602
+ ```typescript
1603
+ openAppStore(options?: OpenAppStoreOptions | undefined) => Promise<void>
1604
+ ```
1605
+
1606
+ Open the app's page in the App Store or Play Store.
1607
+
1608
+ This navigates the user to your app's store listing where they can manually
1609
+ update the app. Use this as a fallback when in-app updates are not available
1610
+ or when the user needs to update on iOS.
1611
+
1612
+ **Platform behavior:**
1613
+ - **Android**: Opens Play Store to the app's page
1614
+ - **iOS**: Opens App Store to the app's page
1615
+
1616
+ **Customization options:**
1617
+ - `appId`: Specify a custom App Store ID (iOS) - useful for opening a different app's page
1618
+ - `packageName`: Specify a custom package name (Android) - useful for opening a different app's page
1619
+
1620
+ | Param | Type | Description |
1621
+ | ------------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
1622
+ | **`options`** | <code><a href="#openappstoreoptions">OpenAppStoreOptions</a></code> | Optional {@link <a href="#openappstoreoptions">OpenAppStoreOptions</a>} to customize which app's store page to open. |
1623
+
1624
+ **Since:** 8.0.0
1625
+
1626
+ --------------------
1627
+
1628
+
1629
+ #### performImmediateUpdate()
1630
+
1631
+ ```typescript
1632
+ performImmediateUpdate() => Promise<AppUpdateResult>
1633
+ ```
1634
+
1635
+ Perform an immediate in-app update on Android.
1636
+
1637
+ This triggers Google Play's immediate update flow, which:
1638
+ 1. Shows a full-screen update UI
1639
+ 2. Downloads and installs the update
1640
+ 3. Restarts the app automatically
1641
+
1642
+ The user cannot continue using the app until the update is complete.
1643
+ This is ideal for critical updates that must be installed immediately.
1644
+
1645
+ **Requirements:**
1646
+ - Android only (throws error on iOS)
1647
+ - An update must be available (check with {@link getAppUpdateInfo} first)
1648
+ - The update must allow immediate updates (`immediateUpdateAllowed: true`)
1649
+
1650
+ **User experience:**
1651
+ - Full-screen blocking UI
1652
+ - Progress shown during download
1653
+ - App automatically restarts after installation
1654
+
1655
+ **Returns:** <code>Promise&lt;<a href="#appupdateresult">AppUpdateResult</a>&gt;</code>
1656
+
1657
+ **Since:** 8.0.0
1658
+
1659
+ --------------------
1660
+
1661
+
1662
+ #### startFlexibleUpdate()
1663
+
1664
+ ```typescript
1665
+ startFlexibleUpdate() => Promise<AppUpdateResult>
1666
+ ```
1667
+
1668
+ Start a flexible in-app update on Android.
1669
+
1670
+ This triggers Google Play's flexible update flow, which:
1671
+ 1. Downloads the update in the background
1672
+ 2. Allows the user to continue using the app
1673
+ 3. Notifies when download is complete
1674
+ 4. Requires calling {@link completeFlexibleUpdate} to install
1675
+
1676
+ Monitor the download progress using the `onFlexibleUpdateStateChange` listener.
1677
+
1678
+ **Requirements:**
1679
+ - Android only (throws error on iOS)
1680
+ - An update must be available (check with {@link getAppUpdateInfo} first)
1681
+ - The update must allow flexible updates (`flexibleUpdateAllowed: true`)
1682
+
1683
+ **Typical flow:**
1684
+ 1. Call `startFlexibleUpdate()` to begin download
1685
+ 2. Listen to `onFlexibleUpdateStateChange` for progress
1686
+ 3. When status is `DOWNLOADED`, prompt user to restart
1687
+ 4. Call `completeFlexibleUpdate()` to install and restart
1688
+
1689
+ **Returns:** <code>Promise&lt;<a href="#appupdateresult">AppUpdateResult</a>&gt;</code>
1690
+
1691
+ **Since:** 8.0.0
1692
+
1693
+ --------------------
1694
+
1695
+
1696
+ #### completeFlexibleUpdate()
1697
+
1698
+ ```typescript
1699
+ completeFlexibleUpdate() => Promise<void>
1700
+ ```
1701
+
1702
+ Complete a flexible in-app update on Android.
1703
+
1704
+ After a flexible update has been downloaded (status `DOWNLOADED` in
1705
+ `onFlexibleUpdateStateChange`), call this method to install the update
1706
+ and restart the app.
1707
+
1708
+ **Important:** This will immediately restart the app. Make sure to:
1709
+ - Save any user data before calling
1710
+ - Prompt the user before restarting
1711
+ - Only call when the download status is `DOWNLOADED`
1712
+
1713
+ **Since:** 8.0.0
1714
+
1715
+ --------------------
1716
+
1717
+
1645
1718
  #### Interfaces
1646
1719
 
1647
1720
 
@@ -1943,6 +2016,17 @@ If you don't use backend, you need to provide the URL and version of the bundle.
1943
2016
  | **`message`** | <code>string</code> | | |
1944
2017
 
1945
2018
 
2019
+ ##### FlexibleUpdateState
2020
+
2021
+ State information for flexible update progress (Android only).
2022
+
2023
+ | Prop | Type | Description | Since |
2024
+ | -------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----- |
2025
+ | **`installStatus`** | <code><a href="#flexibleupdateinstallstatus">FlexibleUpdateInstallStatus</a></code> | The current installation status. | 8.0.0 |
2026
+ | **`bytesDownloaded`** | <code>number</code> | Number of bytes downloaded so far. Only available during the `DOWNLOADING` status. | 8.0.0 |
2027
+ | **`totalBytesToDownload`** | <code>number</code> | Total number of bytes to download. Only available during the `DOWNLOADING` status. | 8.0.0 |
2028
+
2029
+
1946
2030
  ##### AutoUpdateAvailable
1947
2031
 
1948
2032
  | Prop | Type |
@@ -1978,6 +2062,54 @@ If you don't use backend, you need to provide the URL and version of the bundle.
1978
2062
  | **`appId`** | <code>string</code> |
1979
2063
 
1980
2064
 
2065
+ ##### AppUpdateInfo
2066
+
2067
+ Information about app updates available in the App Store or Play Store.
2068
+
2069
+ | Prop | Type | Description | Since |
2070
+ | --------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
2071
+ | **`currentVersionName`** | <code>string</code> | The currently installed version name (e.g., "1.2.3"). | 8.0.0 |
2072
+ | **`availableVersionName`** | <code>string</code> | The version name available in the store, if an update is available. May be undefined if no update information is available. | 8.0.0 |
2073
+ | **`currentVersionCode`** | <code>string</code> | The currently installed version code (Android) or build number (iOS). | 8.0.0 |
2074
+ | **`availableVersionCode`** | <code>string</code> | The version code available in the store (Android only). On iOS, this will be the same as `availableVersionName`. | 8.0.0 |
2075
+ | **`availableVersionReleaseDate`** | <code>string</code> | The release date of the available version (iOS only). Format: ISO 8601 date string. | 8.0.0 |
2076
+ | **`updateAvailability`** | <code><a href="#appupdateavailability">AppUpdateAvailability</a></code> | The current update availability status. | 8.0.0 |
2077
+ | **`updatePriority`** | <code>number</code> | The priority of the update as set by the developer in Play Console (Android only). Values range from 0 (default/lowest) to 5 (highest priority). Use this to decide whether to show an update prompt or force an update. | 8.0.0 |
2078
+ | **`immediateUpdateAllowed`** | <code>boolean</code> | Whether an immediate update is allowed (Android only). If `true`, you can call {@link CapacitorUpdaterPlugin.performImmediateUpdate}. | 8.0.0 |
2079
+ | **`flexibleUpdateAllowed`** | <code>boolean</code> | Whether a flexible update is allowed (Android only). If `true`, you can call {@link CapacitorUpdaterPlugin.startFlexibleUpdate}. | 8.0.0 |
2080
+ | **`clientVersionStalenessDays`** | <code>number</code> | Number of days since the update became available (Android only). Use this to implement "update nagging" - remind users more frequently as the update ages. | 8.0.0 |
2081
+ | **`installStatus`** | <code><a href="#flexibleupdateinstallstatus">FlexibleUpdateInstallStatus</a></code> | The current install status of a flexible update (Android only). | 8.0.0 |
2082
+ | **`minimumOsVersion`** | <code>string</code> | The minimum OS version required for the available update (iOS only). | 8.0.0 |
2083
+
2084
+
2085
+ ##### GetAppUpdateInfoOptions
2086
+
2087
+ Options for {@link CapacitorUpdaterPlugin.getAppUpdateInfo}.
2088
+
2089
+ | Prop | Type | Description | Since |
2090
+ | ------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
2091
+ | **`country`** | <code>string</code> | Two-letter country code (ISO 3166-1 alpha-2) for the App Store lookup. This is required on iOS to get accurate App Store information, as app availability and versions can vary by country. Examples: "US", "GB", "DE", "JP", "FR" On Android, this option is ignored as the Play Store handles region detection automatically. | 8.0.0 |
2092
+
2093
+
2094
+ ##### OpenAppStoreOptions
2095
+
2096
+ Options for {@link CapacitorUpdaterPlugin.openAppStore}.
2097
+
2098
+ | Prop | Type | Description | Since |
2099
+ | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
2100
+ | **`packageName`** | <code>string</code> | The Android package name to open in the Play Store. If not specified, uses the current app's package name. Use this to open a different app's store page. Only used on Android. | 8.0.0 |
2101
+ | **`appId`** | <code>string</code> | The iOS App Store ID to open. If not specified, uses the current app's bundle identifier to look up the app. Use this to open a different app's store page or when automatic lookup fails. Only used on iOS. | 8.0.0 |
2102
+
2103
+
2104
+ ##### AppUpdateResult
2105
+
2106
+ Result of an app update operation.
2107
+
2108
+ | Prop | Type | Description | Since |
2109
+ | ---------- | ------------------------------------------------------------------- | ---------------------------------------- | ----- |
2110
+ | **`code`** | <code><a href="#appupdateresultcode">AppUpdateResultCode</a></code> | The result code of the update operation. | 8.0.0 |
2111
+
2112
+
1981
2113
  #### Type Aliases
1982
2114
 
1983
2115
 
@@ -2002,6 +2134,45 @@ Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvai
2002
2134
 
2003
2135
  <code><a href="#majoravailableevent">MajorAvailableEvent</a></code>
2004
2136
 
2137
+
2138
+ #### Enums
2139
+
2140
+
2141
+ ##### FlexibleUpdateInstallStatus
2142
+
2143
+ | Members | Value | Description |
2144
+ | ----------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------ |
2145
+ | **`UNKNOWN`** | <code>0</code> | Unknown install status. |
2146
+ | **`PENDING`** | <code>1</code> | Download is pending and will start soon. |
2147
+ | **`DOWNLOADING`** | <code>2</code> | Download is in progress. Check `bytesDownloaded` and `totalBytesToDownload` for progress. |
2148
+ | **`INSTALLING`** | <code>3</code> | The update is being installed. |
2149
+ | **`INSTALLED`** | <code>4</code> | The update has been installed. The app needs to be restarted to use the new version. |
2150
+ | **`FAILED`** | <code>5</code> | The update failed to download or install. |
2151
+ | **`CANCELED`** | <code>6</code> | The update was canceled by the user. |
2152
+ | **`DOWNLOADED`** | <code>11</code> | The update has been downloaded and is ready to install. Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install. |
2153
+
2154
+
2155
+ ##### AppUpdateAvailability
2156
+
2157
+ | Members | Value | Description |
2158
+ | -------------------------- | -------------- | ------------------------------------------------------------------------------------------ |
2159
+ | **`UNKNOWN`** | <code>0</code> | Update availability is unknown. This typically means the check hasn't completed or failed. |
2160
+ | **`UPDATE_NOT_AVAILABLE`** | <code>1</code> | No update is available. The installed version is the latest. |
2161
+ | **`UPDATE_AVAILABLE`** | <code>2</code> | An update is available for download. |
2162
+ | **`UPDATE_IN_PROGRESS`** | <code>3</code> | An update is currently being downloaded or installed. |
2163
+
2164
+
2165
+ ##### AppUpdateResultCode
2166
+
2167
+ | Members | Value | Description |
2168
+ | ------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------- |
2169
+ | **`OK`** | <code>0</code> | The update completed successfully. |
2170
+ | **`CANCELED`** | <code>1</code> | The user canceled the update. |
2171
+ | **`FAILED`** | <code>2</code> | The update failed. |
2172
+ | **`NOT_AVAILABLE`** | <code>3</code> | No update is available. |
2173
+ | **`NOT_ALLOWED`** | <code>4</code> | The requested update type is not allowed. For example, trying to perform an immediate update when only flexible is allowed. |
2174
+ | **`INFO_MISSING`** | <code>5</code> | Required information is missing. This can happen if {@link CapacitorUpdaterPlugin.getAppUpdateInfo} wasn't called first. |
2175
+
2005
2176
  </docgen-api>
2006
2177
 
2007
2178
  ### Listen to download events
@@ -57,6 +57,9 @@ dependencies {
57
57
  implementation project(':capacitor-android')
58
58
  implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
59
59
  implementation 'io.github.g00fy2:versioncompare:1.5.0'
60
+ // Play Core library for in-app updates
61
+ implementation 'com.google.android.play:app-update:2.1.0'
62
+ implementation 'com.google.android.play:app-update-ktx:2.1.0'
60
63
  testImplementation "junit:junit:$junitVersion"
61
64
  testImplementation 'org.mockito:mockito-core:5.20.0'
62
65
  testImplementation 'org.json:json:20250517'