@capgo/capacitor-updater 5.41.1 → 5.42.9
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/Package.swift +3 -3
- package/README.md +66 -39
- package/android/build.gradle +5 -3
- package/android/src/main/java/ee/forgr/capacitor_updater/AppLifecycleObserver.java +88 -0
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +82 -16
- package/android/src/main/java/ee/forgr/capacitor_updater/CapgoUpdater.java +188 -11
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipher.java +13 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +32 -10
- package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +36 -14
- package/dist/docs.json +20 -4
- package/dist/esm/definitions.d.ts +19 -4
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Sources/CapacitorUpdaterPlugin/CapacitorUpdaterPlugin.swift +42 -2
- package/ios/Sources/CapacitorUpdaterPlugin/CapgoUpdater.swift +168 -31
- package/ios/Sources/CapacitorUpdaterPlugin/CryptoCipher.swift +9 -1
- package/ios/Sources/CapacitorUpdaterPlugin/InternalUtils.swift +23 -0
- package/package.json +1 -1
package/Package.swift
CHANGED
|
@@ -10,9 +10,9 @@ let package = Package(
|
|
|
10
10
|
targets: ["CapacitorUpdaterPlugin"])
|
|
11
11
|
],
|
|
12
12
|
dependencies: [
|
|
13
|
-
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "
|
|
14
|
-
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.
|
|
15
|
-
.package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.
|
|
13
|
+
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "5.0.0"),
|
|
14
|
+
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.11.0")),
|
|
15
|
+
.package(url: "https://github.com/weichsel/ZIPFoundation.git", from: "0.9.20"),
|
|
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
|
],
|
package/README.md
CHANGED
|
@@ -100,6 +100,8 @@ Starting from v8, the plugin uses [ZIPFoundation](https://github.com/weichsel/ZI
|
|
|
100
100
|
| v3.\*.\* | v3.\*.\* | ⚠️ Deprecated |
|
|
101
101
|
| > 7 | v4.\*.\* | ⚠️ Deprecated, our CI got crazy and bumped too much version |
|
|
102
102
|
|
|
103
|
+
> **Note:** Versions 5, 6, 7, and 8 all share the same features. The major version simply follows your Capacitor version. You can safely use any of these versions that matches your Capacitor installation.
|
|
104
|
+
|
|
103
105
|
### iOS
|
|
104
106
|
|
|
105
107
|
#### Privacy manifest
|
|
@@ -140,6 +142,24 @@ npm install @capgo/capacitor-updater
|
|
|
140
142
|
npx cap sync
|
|
141
143
|
```
|
|
142
144
|
|
|
145
|
+
### Install a specific version
|
|
146
|
+
|
|
147
|
+
Use npm tags to install the version matching your Capacitor version:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# For Capacitor 8 (latest)
|
|
151
|
+
npm install @capgo/capacitor-updater@latest
|
|
152
|
+
|
|
153
|
+
# For Capacitor 7
|
|
154
|
+
npm install @capgo/capacitor-updater@lts-v7
|
|
155
|
+
|
|
156
|
+
# For Capacitor 6
|
|
157
|
+
npm install @capgo/capacitor-updater@lts-v6
|
|
158
|
+
|
|
159
|
+
# For Capacitor 5
|
|
160
|
+
npm install @capgo/capacitor-updater@lts-v5
|
|
161
|
+
```
|
|
162
|
+
|
|
143
163
|
## Auto-update setup
|
|
144
164
|
|
|
145
165
|
Create your account in [capgo.app](https://capgo.app) and get your [API key](https://console.capgo.app/dashboard/apikeys)
|
|
@@ -252,6 +272,10 @@ Capacitor Updater works by unzipping a compiled app bundle to the native device
|
|
|
252
272
|
- Do not password encrypt the bundle zip file, or it will fail to unpack.
|
|
253
273
|
- Make sure the bundle does not contain any extra hidden files or folders, or it may fail to unpack.
|
|
254
274
|
|
|
275
|
+
### Downgrading to a previous version of the updater plugin
|
|
276
|
+
|
|
277
|
+
Downgrading to a previous version of the updater plugin is not supported.
|
|
278
|
+
|
|
255
279
|
## Updater Plugin Config
|
|
256
280
|
|
|
257
281
|
<docgen-config>
|
|
@@ -259,42 +283,43 @@ Capacitor Updater works by unzipping a compiled app bundle to the native device
|
|
|
259
283
|
|
|
260
284
|
CapacitorUpdater can be configured with these options:
|
|
261
285
|
|
|
262
|
-
| Prop | Type | Description
|
|
263
|
-
| ----------------------------- | ------------------------------------------------------------- |
|
|
264
|
-
| **`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.
|
|
265
|
-
| **`responseTimeout`** | <code>number</code> | Configure the number of seconds the native plugin should wait before considering API timeout. Only available for Android and iOS.
|
|
266
|
-
| **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS.
|
|
267
|
-
| **`autoDeletePrevious`** | <code>boolean</code> | Configure whether the plugin should use automatically delete previous bundles after a successful update. Only available for Android and iOS.
|
|
268
|
-
| **`autoUpdate`** | <code>boolean</code> | Configure whether the plugin should use Auto Update via an update server. Only available for Android and iOS.
|
|
269
|
-
| **`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.
|
|
270
|
-
| **`updateUrl`** | <code>string</code> | Configure the URL / endpoint to which update checks are sent. Only available for Android and iOS.
|
|
271
|
-
| **`channelUrl`** | <code>string</code> | Configure the URL / endpoint for channel operations. Only available for Android and iOS.
|
|
272
|
-
| **`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.
|
|
273
|
-
| **`publicKey`** | <code>string</code> | Configure the public key for end to end live update encryption Version 2 Only available for Android and iOS.
|
|
274
|
-
| **`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.
|
|
275
|
-
| **`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 --
|
|
276
|
-
| **`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.
|
|
277
|
-
| **`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.
|
|
278
|
-
| **`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.
|
|
279
|
-
| **`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).
|
|
280
|
-
| **`localS3`** | <code>boolean</code> | Configure the CLI to use a local server for testing or self-hosted update server.
|
|
281
|
-
| **`localHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server.
|
|
282
|
-
| **`localWebHost`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server.
|
|
283
|
-
| **`localSupa`** | <code>string</code> | Configure the CLI to use a local server for testing or self-hosted update server.
|
|
284
|
-
| **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing.
|
|
285
|
-
| **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing.
|
|
286
|
-
| **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing.
|
|
287
|
-
| **`allowModifyUrl`** | <code>boolean</code> | Allow the plugin to modify the updateUrl, statsUrl and channelUrl dynamically from the JavaScript side.
|
|
288
|
-
| **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side.
|
|
289
|
-
| **`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`.
|
|
290
|
-
| **`persistCustomId`** | <code>boolean</code> | Persist the customId set through {@link CapacitorUpdaterPlugin.setCustomId} across app restarts. Only available for Android and iOS.
|
|
291
|
-
| **`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.
|
|
292
|
-
| **`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`.
|
|
293
|
-
| **`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
|
|
294
|
-
| **`appId`** | <code>string</code> | Configure the app id for the app in the config.
|
|
295
|
-
| **`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.
|
|
296
|
-
| **`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
|
|
297
|
-
| **`
|
|
286
|
+
| Prop | Type | Description | Default | Since |
|
|
287
|
+
| ----------------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
|
|
288
|
+
| **`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> | |
|
|
289
|
+
| **`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> | |
|
|
290
|
+
| **`autoDeleteFailed`** | <code>boolean</code> | Configure whether the plugin should use automatically delete failed bundles. Only available for Android and iOS. | <code>true</code> | |
|
|
291
|
+
| **`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> | |
|
|
292
|
+
| **`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> | |
|
|
293
|
+
| **`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> | |
|
|
294
|
+
| **`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> | |
|
|
295
|
+
| **`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> | |
|
|
296
|
+
| **`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> | |
|
|
297
|
+
| **`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 |
|
|
298
|
+
| **`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 |
|
|
299
|
+
| **`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 --delta 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 Activate this flag will automatically make the CLI upload delta in CICD envs and will ask for confirmation in local uploads. Only available for Android and iOS. | <code>false</code> | 5.1.0 |
|
|
300
|
+
| **`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 |
|
|
301
|
+
| **`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 |
|
|
302
|
+
| **`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 |
|
|
303
|
+
| **`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> | |
|
|
304
|
+
| **`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 |
|
|
305
|
+
| **`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 |
|
|
306
|
+
| **`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 |
|
|
307
|
+
| **`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 |
|
|
308
|
+
| **`localSupaAnon`** | <code>string</code> | Configure the CLI to use a local server for testing. | <code>undefined</code> | 4.17.48 |
|
|
309
|
+
| **`localApi`** | <code>string</code> | Configure the CLI to use a local api for testing. | <code>undefined</code> | 6.3.3 |
|
|
310
|
+
| **`localApiFiles`** | <code>string</code> | Configure the CLI to use a local file api for testing. | <code>undefined</code> | 6.3.3 |
|
|
311
|
+
| **`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 |
|
|
312
|
+
| **`allowModifyAppId`** | <code>boolean</code> | Allow the plugin to modify the appId dynamically from the JavaScript side. | <code>false</code> | 7.14.0 |
|
|
313
|
+
| **`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 |
|
|
314
|
+
| **`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 |
|
|
315
|
+
| **`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 |
|
|
316
|
+
| **`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 |
|
|
317
|
+
| **`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 |
|
|
318
|
+
| **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
|
|
319
|
+
| **`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 |
|
|
320
|
+
| **`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 |
|
|
321
|
+
| **`osLogging`** | <code>boolean</code> | Enable OS-level logging. When enabled, logs are written to the system log which can be inspected in production builds. - **iOS**: Uses os_log instead of Swift.print, logs accessible via Console.app or Instruments - **Android**: Logs to Logcat (android.util.Log) When set to false, system logging is disabled on both platforms (only JavaScript console logging will occur if enabled). This is useful for debugging production apps (App Store/TestFlight builds on iOS, or production APKs on Android). | <code>true</code> | 8.42.0 |
|
|
322
|
+
| **`shakeMenu`** | <code>boolean</code> | Enable shake gesture to show update menu for debugging/testing purposes | <code>false</code> | 7.5.0 |
|
|
298
323
|
|
|
299
324
|
### Examples
|
|
300
325
|
|
|
@@ -337,6 +362,7 @@ In `capacitor.config.json`:
|
|
|
337
362
|
"appId": undefined,
|
|
338
363
|
"keepUrlPathAfterReload": undefined,
|
|
339
364
|
"disableJSLogging": undefined,
|
|
365
|
+
"osLogging": undefined,
|
|
340
366
|
"shakeMenu": undefined
|
|
341
367
|
}
|
|
342
368
|
}
|
|
@@ -386,6 +412,7 @@ const config: CapacitorConfig = {
|
|
|
386
412
|
appId: undefined,
|
|
387
413
|
keepUrlPathAfterReload: undefined,
|
|
388
414
|
disableJSLogging: undefined,
|
|
415
|
+
osLogging: undefined,
|
|
389
416
|
shakeMenu: undefined,
|
|
390
417
|
},
|
|
391
418
|
},
|
|
@@ -586,7 +613,7 @@ The URL should point to a zip file containing either:
|
|
|
586
613
|
The bundle must include an `index.html` file at the root level.
|
|
587
614
|
|
|
588
615
|
For encrypted bundles, provide the `sessionKey` and `checksum` parameters.
|
|
589
|
-
For multi-file
|
|
616
|
+
For multi-file delta updates, provide the `manifest` array.
|
|
590
617
|
|
|
591
618
|
| Param | Type | Description |
|
|
592
619
|
| ------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
@@ -885,7 +912,7 @@ The response includes:
|
|
|
885
912
|
- `url`: Download URL for the bundle (if available)
|
|
886
913
|
- `breaking`: Whether this update is marked as incompatible (requires native app update)
|
|
887
914
|
- `message`: Optional message from the server
|
|
888
|
-
- `manifest`: File list for
|
|
915
|
+
- `manifest`: File list for delta updates (if using multi-file downloads)
|
|
889
916
|
|
|
890
917
|
After receiving the latest version info, you can:
|
|
891
918
|
1. Compare it with your current version
|
|
@@ -1979,7 +2006,7 @@ If you don't use backend, you need to provide the URL and version of the bundle.
|
|
|
1979
2006
|
| **`error`** | <code>string</code> | Error code from the server, if any. Common values: - `"no_new_version_available"`: Device is already on the latest version (not a failure) - Other error codes indicate actual failures in the update process | |
|
|
1980
2007
|
| **`old`** | <code>string</code> | The previous/current version name (provided for reference). | |
|
|
1981
2008
|
| **`url`** | <code>string</code> | Download URL for the bundle (when a new version is available). | |
|
|
1982
|
-
| **`manifest`** | <code>ManifestEntry[]</code> | File list for
|
|
2009
|
+
| **`manifest`** | <code>ManifestEntry[]</code> | File list for delta updates (when using multi-file downloads). | 6.1 |
|
|
1983
2010
|
| **`link`** | <code>string</code> | Optional link associated with this bundle version (e.g., release notes URL, changelog, GitHub release). | 7.35.0 |
|
|
1984
2011
|
| **`comment`** | <code>string</code> | Optional comment or description for this bundle version. | 7.35.0 |
|
|
1985
2012
|
|
package/android/build.gradle
CHANGED
|
@@ -50,8 +50,10 @@ repositories {
|
|
|
50
50
|
|
|
51
51
|
dependencies {
|
|
52
52
|
def work_version = "2.10.5"
|
|
53
|
+
def lifecycle_version = "2.10.0"
|
|
53
54
|
implementation "androidx.work:work-runtime:$work_version"
|
|
54
|
-
implementation "
|
|
55
|
+
implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
|
|
56
|
+
implementation "com.google.android.gms:play-services-tasks:18.4.1"
|
|
55
57
|
implementation "com.google.guava:guava:33.5.0-android"
|
|
56
58
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
57
59
|
implementation project(':capacitor-android')
|
|
@@ -61,9 +63,9 @@ dependencies {
|
|
|
61
63
|
implementation 'com.google.android.play:app-update:2.1.0'
|
|
62
64
|
implementation 'com.google.android.play:app-update-ktx:2.1.0'
|
|
63
65
|
testImplementation "junit:junit:$junitVersion"
|
|
64
|
-
testImplementation 'org.mockito:mockito-core:5.
|
|
66
|
+
testImplementation 'org.mockito:mockito-core:5.21.0'
|
|
65
67
|
testImplementation 'org.json:json:20250517'
|
|
66
|
-
testImplementation 'org.robolectric:robolectric:4.
|
|
68
|
+
testImplementation 'org.robolectric:robolectric:4.16.1'
|
|
67
69
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
68
70
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
69
71
|
implementation 'org.brotli:dec:0.1.2'
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
package ee.forgr.capacitor_updater;
|
|
8
|
+
|
|
9
|
+
import androidx.annotation.NonNull;
|
|
10
|
+
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
11
|
+
import androidx.lifecycle.LifecycleOwner;
|
|
12
|
+
import androidx.lifecycle.ProcessLifecycleOwner;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Observes app-level lifecycle events using ProcessLifecycleOwner.
|
|
16
|
+
* This provides reliable detection of when the entire app (not just an activity)
|
|
17
|
+
* moves to foreground or background.
|
|
18
|
+
*
|
|
19
|
+
* Unlike activity lifecycle callbacks, this won't trigger false positives when:
|
|
20
|
+
* - Opening a native camera view
|
|
21
|
+
* - Opening share sheets
|
|
22
|
+
* - Any other native activity overlays within the app
|
|
23
|
+
*
|
|
24
|
+
* The ON_STOP event is dispatched with a ~700ms delay after the last activity
|
|
25
|
+
* passes through onStop(), which helps avoid false triggers during configuration
|
|
26
|
+
* changes or quick activity transitions.
|
|
27
|
+
*/
|
|
28
|
+
public class AppLifecycleObserver implements DefaultLifecycleObserver {
|
|
29
|
+
|
|
30
|
+
public interface AppLifecycleListener {
|
|
31
|
+
void onAppMovedToForeground();
|
|
32
|
+
void onAppMovedToBackground();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private final AppLifecycleListener listener;
|
|
36
|
+
private final Logger logger;
|
|
37
|
+
private boolean isRegistered = false;
|
|
38
|
+
|
|
39
|
+
public AppLifecycleObserver(AppLifecycleListener listener, Logger logger) {
|
|
40
|
+
this.listener = listener;
|
|
41
|
+
this.logger = logger;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public void register() {
|
|
45
|
+
if (isRegistered) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
|
50
|
+
isRegistered = true;
|
|
51
|
+
logger.info("AppLifecycleObserver registered with ProcessLifecycleOwner");
|
|
52
|
+
} catch (Exception e) {
|
|
53
|
+
logger.error("Failed to register AppLifecycleObserver: " + e.getMessage());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public void unregister() {
|
|
58
|
+
if (!isRegistered) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
ProcessLifecycleOwner.get().getLifecycle().removeObserver(this);
|
|
63
|
+
isRegistered = false;
|
|
64
|
+
logger.info("AppLifecycleObserver unregistered from ProcessLifecycleOwner");
|
|
65
|
+
} catch (Exception e) {
|
|
66
|
+
logger.error("Failed to unregister AppLifecycleObserver: " + e.getMessage());
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@Override
|
|
71
|
+
public void onStart(@NonNull LifecycleOwner owner) {
|
|
72
|
+
// App moved to foreground (at least one activity is visible)
|
|
73
|
+
logger.info("ProcessLifecycleOwner: App moved to foreground");
|
|
74
|
+
if (listener != null) {
|
|
75
|
+
listener.onAppMovedToForeground();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Override
|
|
80
|
+
public void onStop(@NonNull LifecycleOwner owner) {
|
|
81
|
+
// App moved to background (no activities are visible)
|
|
82
|
+
// Note: This is called with a ~700ms delay to avoid false triggers
|
|
83
|
+
logger.info("ProcessLifecycleOwner: App moved to background");
|
|
84
|
+
if (listener != null) {
|
|
85
|
+
listener.onAppMovedToBackground();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|