@capgo/capacitor-updater 7.39.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)
@@ -444,7 +316,6 @@ export default config;
444
316
  * [`performImmediateUpdate()`](#performimmediateupdate)
445
317
  * [`startFlexibleUpdate()`](#startflexibleupdate)
446
318
  * [`completeFlexibleUpdate()`](#completeflexibleupdate)
447
- * [`addListener('onFlexibleUpdateStateChange', ...)`](#addlisteneronflexibleupdatestatechange-)
448
319
  * [Interfaces](#interfaces)
449
320
  * [Type Aliases](#type-aliases)
450
321
  * [Enums](#enums)
@@ -1451,6 +1322,43 @@ This event is useful for:
1451
1322
  --------------------
1452
1323
 
1453
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
+
1454
1362
  #### isAutoUpdateAvailable()
1455
1363
 
1456
1364
  ```typescript
@@ -1807,43 +1715,6 @@ and restart the app.
1807
1715
  --------------------
1808
1716
 
1809
1717
 
1810
- #### addListener('onFlexibleUpdateStateChange', ...)
1811
-
1812
- ```typescript
1813
- addListener(eventName: 'onFlexibleUpdateStateChange', listenerFunc: (state: FlexibleUpdateState) => void) => Promise<PluginListenerHandle>
1814
- ```
1815
-
1816
- Listen for flexible update state changes on Android.
1817
-
1818
- This event fires during the flexible update download process, providing:
1819
- - Download progress (bytes downloaded / total bytes)
1820
- - Installation status changes
1821
-
1822
- **Install status values:**
1823
- - `UNKNOWN` (0): Unknown status
1824
- - `PENDING` (1): Download pending
1825
- - `DOWNLOADING` (2): Download in progress
1826
- - `INSTALLING` (3): Installing the update
1827
- - `INSTALLED` (4): Update installed (app restart needed)
1828
- - `FAILED` (5): Update failed
1829
- - `CANCELED` (6): Update was canceled
1830
- - `DOWNLOADED` (11): Download complete, ready to install
1831
-
1832
- When status is `DOWNLOADED`, you should prompt the user and call
1833
- {@link completeFlexibleUpdate} to finish the installation.
1834
-
1835
- | Param | Type |
1836
- | ------------------ | --------------------------------------------------------------------------------------- |
1837
- | **`eventName`** | <code>'onFlexibleUpdateStateChange'</code> |
1838
- | **`listenerFunc`** | <code>(state: <a href="#flexibleupdatestate">FlexibleUpdateState</a>) =&gt; void</code> |
1839
-
1840
- **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
1841
-
1842
- **Since:** 8.0.0
1843
-
1844
- --------------------
1845
-
1846
-
1847
1718
  #### Interfaces
1848
1719
 
1849
1720
 
@@ -2145,6 +2016,17 @@ If you don't use backend, you need to provide the URL and version of the bundle.
2145
2016
  | **`message`** | <code>string</code> | | |
2146
2017
 
2147
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
+
2148
2030
  ##### AutoUpdateAvailable
2149
2031
 
2150
2032
  | Prop | Type |
@@ -2228,17 +2110,6 @@ Result of an app update operation.
2228
2110
  | **`code`** | <code><a href="#appupdateresultcode">AppUpdateResultCode</a></code> | The result code of the update operation. | 8.0.0 |
2229
2111
 
2230
2112
 
2231
- ##### FlexibleUpdateState
2232
-
2233
- State information for flexible update progress (Android only).
2234
-
2235
- | Prop | Type | Description | Since |
2236
- | -------------------------- | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----- |
2237
- | **`installStatus`** | <code><a href="#flexibleupdateinstallstatus">FlexibleUpdateInstallStatus</a></code> | The current installation status. | 8.0.0 |
2238
- | **`bytesDownloaded`** | <code>number</code> | Number of bytes downloaded so far. Only available during the `DOWNLOADING` status. | 8.0.0 |
2239
- | **`totalBytesToDownload`** | <code>number</code> | Total number of bytes to download. Only available during the `DOWNLOADING` status. | 8.0.0 |
2240
-
2241
-
2242
2113
  #### Type Aliases
2243
2114
 
2244
2115
 
@@ -2267,16 +2138,6 @@ Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvai
2267
2138
  #### Enums
2268
2139
 
2269
2140
 
2270
- ##### AppUpdateAvailability
2271
-
2272
- | Members | Value | Description |
2273
- | -------------------------- | -------------- | ------------------------------------------------------------------------------------------ |
2274
- | **`UNKNOWN`** | <code>0</code> | Update availability is unknown. This typically means the check hasn't completed or failed. |
2275
- | **`UPDATE_NOT_AVAILABLE`** | <code>1</code> | No update is available. The installed version is the latest. |
2276
- | **`UPDATE_AVAILABLE`** | <code>2</code> | An update is available for download. |
2277
- | **`UPDATE_IN_PROGRESS`** | <code>3</code> | An update is currently being downloaded or installed. |
2278
-
2279
-
2280
2141
  ##### FlexibleUpdateInstallStatus
2281
2142
 
2282
2143
  | Members | Value | Description |
@@ -2291,6 +2152,16 @@ Payload emitted by {@link CapacitorUpdaterPlugin.addListener} with `breakingAvai
2291
2152
  | **`DOWNLOADED`** | <code>11</code> | The update has been downloaded and is ready to install. Call {@link CapacitorUpdaterPlugin.completeFlexibleUpdate} to install. |
2292
2153
 
2293
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
+
2294
2165
  ##### AppUpdateResultCode
2295
2166
 
2296
2167
  | Members | Value | Description |
@@ -9,10 +9,12 @@ package ee.forgr.capacitor_updater;
9
9
  import android.app.Activity;
10
10
  import android.app.ActivityManager;
11
11
  import android.content.Context;
12
+ import android.content.Intent;
12
13
  import android.content.SharedPreferences;
13
14
  import android.content.pm.PackageInfo;
14
15
  import android.content.pm.PackageManager;
15
16
  import android.graphics.Color;
17
+ import android.net.Uri;
16
18
  import android.os.Build;
17
19
  import android.os.Handler;
18
20
  import android.os.Looper;
@@ -30,6 +32,17 @@ import com.getcapacitor.PluginHandle;
30
32
  import com.getcapacitor.PluginMethod;
31
33
  import com.getcapacitor.annotation.CapacitorPlugin;
32
34
  import com.getcapacitor.plugin.WebView;
35
+ import com.google.android.gms.tasks.Task;
36
+ // Play Store In-App Updates
37
+ import com.google.android.play.core.appupdate.AppUpdateInfo;
38
+ import com.google.android.play.core.appupdate.AppUpdateManager;
39
+ import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
40
+ import com.google.android.play.core.appupdate.AppUpdateOptions;
41
+ import com.google.android.play.core.install.InstallState;
42
+ import com.google.android.play.core.install.InstallStateUpdatedListener;
43
+ import com.google.android.play.core.install.model.AppUpdateType;
44
+ import com.google.android.play.core.install.model.InstallStatus;
45
+ import com.google.android.play.core.install.model.UpdateAvailability;
33
46
  import io.github.g00fy2.versioncompare.Version;
34
47
  import java.io.IOException;
35
48
  import java.net.MalformedURLException;
@@ -55,20 +68,6 @@ import org.json.JSONArray;
55
68
  import org.json.JSONException;
56
69
  import org.json.JSONObject;
57
70
 
58
- // Play Store In-App Updates
59
- import com.google.android.play.core.appupdate.AppUpdateInfo;
60
- import com.google.android.play.core.appupdate.AppUpdateManager;
61
- import com.google.android.play.core.appupdate.AppUpdateManagerFactory;
62
- import com.google.android.play.core.appupdate.AppUpdateOptions;
63
- import com.google.android.play.core.install.InstallState;
64
- import com.google.android.play.core.install.InstallStateUpdatedListener;
65
- import com.google.android.play.core.install.model.AppUpdateType;
66
- import com.google.android.play.core.install.model.InstallStatus;
67
- import com.google.android.play.core.install.model.UpdateAvailability;
68
- import com.google.android.gms.tasks.Task;
69
- import android.content.Intent;
70
- import android.net.Uri;
71
-
72
71
  @CapacitorPlugin(name = "CapacitorUpdater")
73
72
  public class CapacitorUpdaterPlugin extends Plugin {
74
73
 
@@ -86,7 +85,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
86
85
  private static final String[] BREAKING_EVENT_NAMES = { "breakingAvailable", "majorAvailable" };
87
86
  private static final String LAST_FAILED_BUNDLE_PREF_KEY = "CapacitorUpdater.lastFailedBundle";
88
87
 
89
- private final String pluginVersion = "7.39.0";
88
+ private final String pluginVersion = "7.40.0";
90
89
  private static final String DELAY_CONDITION_PREFERENCES = "";
91
90
 
92
91
  private SharedPreferences.Editor editor;
@@ -2131,9 +2130,6 @@ public class CapacitorUpdaterPlugin extends Plugin {
2131
2130
  }
2132
2131
 
2133
2132
  private boolean isMainActivity() {
2134
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
2135
- return false;
2136
- }
2137
2133
  try {
2138
2134
  Context mContext = this.getContext();
2139
2135
  ActivityManager activityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
@@ -2331,45 +2327,47 @@ public class CapacitorUpdaterPlugin extends Plugin {
2331
2327
  AppUpdateManager manager = getAppUpdateManager();
2332
2328
  Task<AppUpdateInfo> appUpdateInfoTask = manager.getAppUpdateInfo();
2333
2329
 
2334
- appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {
2335
- cachedAppUpdateInfo = appUpdateInfo;
2330
+ appUpdateInfoTask
2331
+ .addOnSuccessListener((appUpdateInfo) -> {
2332
+ cachedAppUpdateInfo = appUpdateInfo;
2336
2333
 
2337
- JSObject result = new JSObject();
2338
- try {
2339
- PackageInfo pInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
2340
- result.put("currentVersionName", pInfo.versionName);
2341
- result.put("currentVersionCode", String.valueOf(pInfo.versionCode));
2342
- } catch (PackageManager.NameNotFoundException e) {
2343
- result.put("currentVersionName", "0.0.0");
2344
- result.put("currentVersionCode", "0");
2345
- }
2334
+ JSObject result = new JSObject();
2335
+ try {
2336
+ PackageInfo pInfo = getContext().getPackageManager().getPackageInfo(getContext().getPackageName(), 0);
2337
+ result.put("currentVersionName", pInfo.versionName);
2338
+ result.put("currentVersionCode", String.valueOf(pInfo.versionCode));
2339
+ } catch (PackageManager.NameNotFoundException e) {
2340
+ result.put("currentVersionName", "0.0.0");
2341
+ result.put("currentVersionCode", "0");
2342
+ }
2346
2343
 
2347
- result.put("updateAvailability", mapUpdateAvailability(appUpdateInfo.updateAvailability()));
2344
+ result.put("updateAvailability", mapUpdateAvailability(appUpdateInfo.updateAvailability()));
2348
2345
 
2349
- if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
2350
- result.put("availableVersionCode", String.valueOf(appUpdateInfo.availableVersionCode()));
2351
- // Play Store doesn't provide version name, only version code
2352
- result.put("availableVersionName", String.valueOf(appUpdateInfo.availableVersionCode()));
2353
- result.put("updatePriority", appUpdateInfo.updatePriority());
2354
- result.put("immediateUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE));
2355
- result.put("flexibleUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE));
2346
+ if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
2347
+ result.put("availableVersionCode", String.valueOf(appUpdateInfo.availableVersionCode()));
2348
+ // Play Store doesn't provide version name, only version code
2349
+ result.put("availableVersionName", String.valueOf(appUpdateInfo.availableVersionCode()));
2350
+ result.put("updatePriority", appUpdateInfo.updatePriority());
2351
+ result.put("immediateUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE));
2352
+ result.put("flexibleUpdateAllowed", appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE));
2356
2353
 
2357
- Integer stalenessDays = appUpdateInfo.clientVersionStalenessDays();
2358
- if (stalenessDays != null) {
2359
- result.put("clientVersionStalenessDays", stalenessDays);
2354
+ Integer stalenessDays = appUpdateInfo.clientVersionStalenessDays();
2355
+ if (stalenessDays != null) {
2356
+ result.put("clientVersionStalenessDays", stalenessDays);
2357
+ }
2358
+ } else {
2359
+ result.put("immediateUpdateAllowed", false);
2360
+ result.put("flexibleUpdateAllowed", false);
2360
2361
  }
2361
- } else {
2362
- result.put("immediateUpdateAllowed", false);
2363
- result.put("flexibleUpdateAllowed", false);
2364
- }
2365
2362
 
2366
- result.put("installStatus", appUpdateInfo.installStatus());
2363
+ result.put("installStatus", appUpdateInfo.installStatus());
2367
2364
 
2368
- call.resolve(result);
2369
- }).addOnFailureListener(e -> {
2370
- logger.error("Failed to get app update info: " + e.getMessage());
2371
- call.reject("Failed to get app update info: " + e.getMessage());
2372
- });
2365
+ call.resolve(result);
2366
+ })
2367
+ .addOnFailureListener((e) -> {
2368
+ logger.error("Failed to get app update info: " + e.getMessage());
2369
+ call.reject("Failed to get app update info: " + e.getMessage());
2370
+ });
2373
2371
  } catch (Exception e) {
2374
2372
  logger.error("Error getting app update info: " + e.getMessage());
2375
2373
  call.reject("Error getting app update info: " + e.getMessage());
@@ -2392,8 +2390,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
2392
2390
  } catch (android.content.ActivityNotFoundException e) {
2393
2391
  // Fall back to browser
2394
2392
  try {
2395
- Intent intent = new Intent(Intent.ACTION_VIEW,
2396
- Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
2393
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + packageName));
2397
2394
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
2398
2395
  getContext().startActivity(intent);
2399
2396
  call.resolve();
@@ -2496,7 +2493,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
2496
2493
  manager.unregisterListener(installStateUpdatedListener);
2497
2494
  }
2498
2495
 
2499
- installStateUpdatedListener = state -> {
2496
+ installStateUpdatedListener = (state) -> {
2500
2497
  JSObject eventData = new JSObject();
2501
2498
  eventData.put("installStatus", state.installStatus());
2502
2499
 
@@ -2531,12 +2528,13 @@ public class CapacitorUpdaterPlugin extends Plugin {
2531
2528
  public void completeFlexibleUpdate(final PluginCall call) {
2532
2529
  try {
2533
2530
  AppUpdateManager manager = getAppUpdateManager();
2534
- manager.completeUpdate()
2535
- .addOnSuccessListener(aVoid -> {
2531
+ manager
2532
+ .completeUpdate()
2533
+ .addOnSuccessListener((aVoid) -> {
2536
2534
  // The app will restart, so this may not be called
2537
2535
  call.resolve();
2538
2536
  })
2539
- .addOnFailureListener(e -> {
2537
+ .addOnFailureListener((e) -> {
2540
2538
  logger.error("Failed to complete flexible update: " + e.getMessage());
2541
2539
  call.reject("Failed to complete flexible update: " + e.getMessage());
2542
2540
  });