@capawesome/capacitor-live-update 8.4.3 → 8.5.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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ Capacitor plugin that allows you to update your app remotely in real-time withou
12
12
 
13
13
  The Capacitor Live Update plugin is one of the most feature-rich Over-the-Air (OTA) update solutions for Capacitor apps. Here are some of the key features:
14
14
 
15
- - 🔋 Supports **Android and iOS**
15
+ - 🔋 Supports **Android, iOS and Electron**
16
16
  - ⚡️ **Capacitor 6/7/8** support
17
17
  - 📦 **Bundle Management**: Download, set, and delete bundles.
18
18
  - ☁️ **Cloud Support**: Use the [Capawesome Cloud](https://cloud.capawesome.io/) to manage your app updates.
@@ -51,6 +51,14 @@ The Live Update plugin is typically used to ship changes to users without going
51
51
  | 6.x.x | 6.x.x | Maintenance |
52
52
  | 5.x.x | 5.x.x | Deprecated |
53
53
 
54
+ ## Demo
55
+
56
+ A working example can be found here: [capawesome-team/capacitor-live-update-demo](https://github.com/capawesome-team/capacitor-live-update-demo)
57
+
58
+ | Android | iOS |
59
+ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
60
+ | <img src="https://raw.githubusercontent.com/capawesome-team/capacitor-plugins/main/packages/live-update/.github/assets/demo-android.png" width="324" alt="Android Demo" /> | <img src="https://raw.githubusercontent.com/capawesome-team/capacitor-plugins/main/packages/live-update/.github/assets/demo-ios.png" width="324" alt="iOS Demo" /> |
61
+
54
62
  ## Guides
55
63
 
56
64
  - [Getting Started with Capawesome Cloud Live Updates](https://capawesome.io/docs/cloud/live-updates/setup/)
@@ -152,22 +160,52 @@ Add the `NSPrivacyAccessedAPICategoryUserDefaults` dictionary key to your [Priva
152
160
 
153
161
  We recommend to declare [`CA92.1`](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278401) as the reason for accessing the [`UserDefaults`](https://developer.apple.com/documentation/foundation/userdefaults) API.
154
162
 
163
+ ### Electron
164
+
165
+ This plugin supports the [Capacitor Electron platform](https://github.com/capawesome-team/capacitor-electron) (`@capawesome/capacitor-electron` version `0.2.0` or later). No additional configuration is required.
166
+
167
+ Please note the following differences on Electron:
168
+
169
+ - The app version is the `version` from your `electron/package.json` file, so make sure to maintain it.
170
+ - Only the `zip` artifact type is supported.
171
+ - Bundles and state are stored in the `capawesome-live-update` directory inside the app's [`userData`](https://www.electronjs.org/docs/latest/api/app#appgetpathname) directory.
172
+ - The rollback is kill-safe: if the app is closed or crashes before `ready()` is called, the rollback is performed on the next app start.
173
+
174
+ #### Channel
175
+
176
+ If you are using [Versioned Channels](https://capawesome.io/docs/cloud/live-updates/channels/#versioned-channels), you can set a default channel in your `electron/capacitor.electron.config.ts` file.
177
+ This configuration takes precedence over the Capacitor configuration and allows you to tie the channel to the app version:
178
+
179
+ ```ts
180
+ import { defineConfig } from '@capawesome/capacitor-electron/config';
181
+
182
+ import packageJson from './package.json';
183
+
184
+ export default defineConfig({
185
+ plugins: {
186
+ LiveUpdate: {
187
+ defaultChannel: `production-${packageJson.version}`,
188
+ },
189
+ },
190
+ });
191
+ ```
192
+
155
193
  ## Configuration
156
194
 
157
195
  <docgen-config>
158
196
  <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
159
197
 
160
- | Prop | Type | Description | Default | Since |
161
- | -------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | ----- |
162
- | **`appId`** | <code>string</code> | The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/). This is **NOT** the same as the app identifier (e.g. `com.example.app`). This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`). | | 5.0.0 |
163
- | **`autoBlockRolledBackBundles`** | <code>boolean</code> | Whether or not to automatically block bundles that have been rolled back. When enabled, the plugin will automatically block bundles that caused a rollback (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked. Blocked bundles will be skipped in future sync operations. **Attention**: This option has no effect if `readyTimeout` is set to `0`. Only available on Android and iOS. | <code>false</code> | 7.3.0 |
164
- | **`autoDeleteBundles`** | <code>boolean</code> | Whether or not to automatically delete unused bundles. When enabled, the plugin will automatically delete unused bundles after calling `ready()`. | <code>false</code> | 5.0.0 |
165
- | **`autoUpdateStrategy`** | <code>'none' \| 'background'</code> | The auto-update strategy for live updates. - `none`: Live updates will not be applied automatically. - `background`: Live updates will be automatically downloaded and applied in the background at app startup and when the app resumes (if the last check was more than 15 minutes ago). Only available on Android and iOS. | <code>'none'</code> | 7.3.0 |
166
- | **`defaultChannel`** | <code>string</code> | The default channel of the app. This can be overridden by `setChannel()`, the `channel` parameter of `sync()`, or the native channel configuration (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or `capawesome_live_update_default_channel` in `strings.xml` on Android). | | 6.3.0 |
167
- | **`httpTimeout`** | <code>number</code> | The timeout in milliseconds for HTTP requests. | <code>60000</code> | 6.4.0 |
168
- | **`publicKey`** | <code>string</code> | The public key to verify the integrity of the bundle. The public key must be a PEM-encoded RSA public key. | | 6.1.0 |
169
- | **`readyTimeout`** | <code>number</code> | The timeout in milliseconds to wait for the app to be ready before resetting to the default bundle. It is strongly **recommended** to configure this option (e.g. `10000` ms) so that the plugin can roll back to the default bundle in case of problems. If configured, the plugin will wait for the app to call the `ready()` method before resetting to the default bundle. Set to `0` to disable the timeout. | <code>0</code> | 5.0.0 |
170
- | **`serverDomain`** | <code>string</code> | The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path. | <code>'api.cloud.capawesome.io'</code> | 7.0.0 |
198
+ | Prop | Type | Description | Default | Since |
199
+ | -------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | ----- |
200
+ | **`appId`** | <code>string</code> | The app ID is used to identify the app when using [Capawesome Cloud](https://capawesome.io/cloud/). This is **NOT** the same as the app identifier (e.g. `com.example.app`). This is a unique identifier generated by Capawesome Cloud (e.g. `6e351b4f-69a7-415e-a057-4567df7ffe94`). | | 5.0.0 |
201
+ | **`autoBlockRolledBackBundles`** | <code>boolean</code> | Whether or not to automatically block bundles that have been rolled back. When enabled, the plugin will automatically block bundles that caused a rollback (up to 100 bundles). When the limit is reached, the oldest blocked bundle is unblocked. Blocked bundles will be skipped in future sync operations. **Attention**: This option has no effect if `readyTimeout` is set to `0`. Only available on Android, iOS and Electron. | <code>false</code> | 7.3.0 |
202
+ | **`autoDeleteBundles`** | <code>boolean</code> | Whether or not to automatically delete unused bundles. When enabled, the plugin will automatically delete unused bundles after calling `ready()`. | <code>false</code> | 5.0.0 |
203
+ | **`autoUpdateStrategy`** | <code>'none' \| 'background'</code> | The auto-update strategy for live updates. - `none`: Live updates will not be applied automatically. - `background`: Live updates will be automatically downloaded and applied in the background at app startup and when the app resumes (if the last check was more than 15 minutes ago). Only available on Android, iOS and Electron. | <code>'none'</code> | 7.3.0 |
204
+ | **`defaultChannel`** | <code>string</code> | The default channel of the app. This can be overridden by `setChannel()`, the `channel` parameter of `sync()`, or the native channel configuration (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS, `capawesome_live_update_default_channel` in `strings.xml` on Android or `electron/capacitor.electron.config.ts` on Electron). | | 6.3.0 |
205
+ | **`httpTimeout`** | <code>number</code> | The timeout in milliseconds for HTTP requests. | <code>60000</code> | 6.4.0 |
206
+ | **`publicKey`** | <code>string</code> | The public key to verify the integrity of the bundle. The public key must be a PEM-encoded RSA public key. | | 6.1.0 |
207
+ | **`readyTimeout`** | <code>number</code> | The timeout in milliseconds to wait for the app to be ready before resetting to the default bundle. It is strongly **recommended** to configure this option (e.g. `10000` ms) so that the plugin can roll back to the default bundle in case of problems. If configured, the plugin will wait for the app to call the `ready()` method before resetting to the default bundle. Set to `0` to disable the timeout. | <code>0</code> | 5.0.0 |
208
+ | **`serverDomain`** | <code>string</code> | The API domain of the [Capawesome Cloud](https://cloud.capawesome.io) server **without** scheme or path. | <code>'api.cloud.capawesome.io'</code> | 7.0.0 |
171
209
 
172
210
  ### Examples
173
211
 
@@ -219,14 +257,6 @@ export default config;
219
257
 
220
258
  </docgen-config>
221
259
 
222
- ## Demo
223
-
224
- A working example can be found here: [capawesome-team/capacitor-live-update-demo](https://github.com/capawesome-team/capacitor-live-update-demo)
225
-
226
- | Android | iOS |
227
- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
228
- | <img src="https://raw.githubusercontent.com/capawesome-team/capacitor-plugins/main/packages/live-update/.github/assets/demo-android.png" width="324" alt="Android Demo" /> | <img src="https://raw.githubusercontent.com/capawesome-team/capacitor-plugins/main/packages/live-update/.github/assets/demo-ios.png" width="324" alt="iOS Demo" /> |
229
-
230
260
  ## Usage
231
261
 
232
262
  All methods are only available on Android and iOS. The following examples show how to sync with Capawesome Cloud, mark the app as ready, check for and download new bundles, switch between and manage bundles, work with channels, inspect the current and next bundle, identify devices, read the app version, and reset to the default bundle.
@@ -481,7 +511,7 @@ Clear all blocked bundles from the blocked list.
481
511
  This removes all bundle identifiers that were automatically blocked
482
512
  due to rollbacks when `autoBlockRolledBackBundles` is enabled.
483
513
 
484
- Only available on Android and iOS.
514
+ Only available on Android, iOS and Electron.
485
515
 
486
516
  **Since:** 7.4.0
487
517
 
@@ -496,7 +526,7 @@ deleteBundle(options: DeleteBundleOptions) => Promise<void>
496
526
 
497
527
  Delete a bundle from the app.
498
528
 
499
- Only available on Android and iOS.
529
+ Only available on Android, iOS and Electron.
500
530
 
501
531
  | Param | Type |
502
532
  | ------------- | ------------------------------------------------------------------- |
@@ -515,7 +545,7 @@ downloadBundle(options: DownloadBundleOptions) => Promise<void>
515
545
 
516
546
  Download a bundle.
517
547
 
518
- Only available on Android and iOS.
548
+ Only available on Android, iOS and Electron.
519
549
 
520
550
  | Param | Type |
521
551
  | ------------- | ----------------------------------------------------------------------- |
@@ -542,7 +572,7 @@ dynamically switch between them using `setChannel(...)`.
542
572
  If channels are private, they can still be set using `setChannel(...)`
543
573
  but won't be returned by this method.
544
574
 
545
- Only available on Android and iOS.
575
+ Only available on Android, iOS and Electron.
546
576
 
547
577
  | Param | Type |
548
578
  | ------------- | --------------------------------------------------------------------- |
@@ -563,7 +593,7 @@ fetchLatestBundle(options?: FetchLatestBundleOptions | undefined) => Promise<Fet
563
593
 
564
594
  Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).
565
595
 
566
- Only available on Android and iOS.
596
+ Only available on Android, iOS and Electron.
567
597
 
568
598
  | Param | Type |
569
599
  | ------------- | ----------------------------------------------------------------------------- |
@@ -587,7 +617,7 @@ Get all blocked bundle identifiers.
587
617
  Returns the list of bundle identifiers that were automatically blocked
588
618
  due to rollbacks when `autoBlockRolledBackBundles` is enabled.
589
619
 
590
- Only available on Android and iOS.
620
+ Only available on Android, iOS and Electron.
591
621
 
592
622
  **Returns:** <code>Promise&lt;<a href="#getblockedbundlesresult">GetBlockedBundlesResult</a>&gt;</code>
593
623
 
@@ -604,7 +634,7 @@ getBundles() => Promise<GetBundlesResult>
604
634
 
605
635
  Get all identifiers of bundles that have been downloaded.
606
636
 
607
- Only available on Android and iOS.
637
+ Only available on Android, iOS and Electron.
608
638
 
609
639
  **Returns:** <code>Promise&lt;<a href="#getbundlesresult">GetBundlesResult</a>&gt;</code>
610
640
 
@@ -623,14 +653,15 @@ Get the channel that is used for the update.
623
653
 
624
654
  The channel is resolved in the following order (highest priority first):
625
655
  1. `setChannel()` (SharedPreferences on Android / UserDefaults on iOS)
626
- 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS or
627
- `capawesome_live_update_default_channel` in `strings.xml` on Android)
656
+ 2. Native config (`CapawesomeLiveUpdateDefaultChannel` in `Info.plist` on iOS,
657
+ `capawesome_live_update_default_channel` in `strings.xml` on Android or
658
+ `defaultChannel` in `electron/capacitor.electron.config.ts` on Electron)
628
659
  3. Capacitor config `defaultChannel`
629
660
 
630
661
  **Note**: The `channel` parameter of `sync()` takes the highest priority
631
662
  but is not persisted and therefore not returned by this method.
632
663
 
633
- Only available on Android and iOS.
664
+ Only available on Android, iOS and Electron.
634
665
 
635
666
  **Returns:** <code>Promise&lt;<a href="#getchannelresult">GetChannelResult</a>&gt;</code>
636
667
 
@@ -650,7 +681,7 @@ Get the runtime configuration.
650
681
  Returns the current plugin configuration including any runtime
651
682
  overrides set via `setConfig()`.
652
683
 
653
- Only available on Android and iOS.
684
+ Only available on Android, iOS and Electron.
654
685
 
655
686
  **Returns:** <code>Promise&lt;<a href="#getconfigresult">GetConfigResult</a>&gt;</code>
656
687
 
@@ -667,7 +698,7 @@ getDownloadedBundles() => Promise<GetDownloadedBundlesResult>
667
698
 
668
699
  Get all identifiers of bundles that have been downloaded.
669
700
 
670
- Only available on Android and iOS.
701
+ Only available on Android, iOS and Electron.
671
702
 
672
703
  **Returns:** <code>Promise&lt;<a href="#getdownloadedbundlesresult">GetDownloadedBundlesResult</a>&gt;</code>
673
704
 
@@ -685,7 +716,7 @@ getCurrentBundle() => Promise<GetCurrentBundleResult>
685
716
  Get the bundle identifier of the current bundle.
686
717
  The current bundle is the bundle that is currently used by the app.
687
718
 
688
- Only available on Android and iOS.
719
+ Only available on Android, iOS and Electron.
689
720
 
690
721
  **Returns:** <code>Promise&lt;<a href="#getcurrentbundleresult">GetCurrentBundleResult</a>&gt;</code>
691
722
 
@@ -702,7 +733,7 @@ getCustomId() => Promise<GetCustomIdResult>
702
733
 
703
734
  Get the custom identifier of the device.
704
735
 
705
- Only available on Android and iOS.
736
+ Only available on Android, iOS and Electron.
706
737
 
707
738
  **Returns:** <code>Promise&lt;<a href="#getcustomidresult">GetCustomIdResult</a>&gt;</code>
708
739
 
@@ -719,7 +750,7 @@ getDeviceId() => Promise<GetDeviceIdResult>
719
750
 
720
751
  Get the unique device identifier.
721
752
 
722
- Only available on Android and iOS.
753
+ Only available on Android, iOS and Electron.
723
754
 
724
755
  **Returns:** <code>Promise&lt;<a href="#getdeviceidresult">GetDeviceIdResult</a>&gt;</code>
725
756
 
@@ -736,7 +767,7 @@ isSyncing() => Promise<IsSyncingResult>
736
767
 
737
768
  Check whether a sync operation is currently in progress.
738
769
 
739
- Only available on Android and iOS.
770
+ Only available on Android, iOS and Electron.
740
771
 
741
772
  **Returns:** <code>Promise&lt;<a href="#issyncingresult">IsSyncingResult</a>&gt;</code>
742
773
 
@@ -755,7 +786,7 @@ Get the bundle identifier of the next bundle.
755
786
  The next bundle is the bundle that will be used after calling `reload()`
756
787
  or restarting the app.
757
788
 
758
- Only available on Android and iOS.
789
+ Only available on Android, iOS and Electron.
759
790
 
760
791
  **Returns:** <code>Promise&lt;<a href="#getnextbundleresult">GetNextBundleResult</a>&gt;</code>
761
792
 
@@ -774,8 +805,9 @@ Get the version code of the app.
774
805
 
775
806
  On **Android**, this is the `versionCode` from the `android/app/build.gradle` file.
776
807
  On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file.
808
+ On **Electron**, this is the `version` from the `electron/package.json` file.
777
809
 
778
- Only available on Android and iOS.
810
+ Only available on Android, iOS and Electron.
779
811
 
780
812
  **Returns:** <code>Promise&lt;<a href="#getversioncoderesult">GetVersionCodeResult</a>&gt;</code>
781
813
 
@@ -794,8 +826,9 @@ Get the version name of the app.
794
826
 
795
827
  On **Android**, this is the `versionName` from the `android/app/build.gradle` file.
796
828
  On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file.
829
+ On **Electron**, this is the `version` from the `electron/package.json` file.
797
830
 
798
- Only available on Android and iOS.
831
+ Only available on Android, iOS and Electron.
799
832
 
800
833
  **Returns:** <code>Promise&lt;<a href="#getversionnameresult">GetVersionNameResult</a>&gt;</code>
801
834
 
@@ -816,7 +849,7 @@ Notify the plugin that the app is ready to use and no rollback is needed.
816
849
  to prevent the app from being reset to the default bundle.
817
850
  It must always be called before `sync(...)` or any other method that changes the bundle.
818
851
 
819
- Only available on Android and iOS.
852
+ Only available on Android, iOS and Electron.
820
853
 
821
854
  **Returns:** <code>Promise&lt;<a href="#readyresult">ReadyResult</a>&gt;</code>
822
855
 
@@ -841,7 +874,7 @@ on the next app start instead.
841
874
 
842
875
  **Attention**: The in-memory state of the app (e.g. unsaved user input) is lost.
843
876
 
844
- Only available on Android and iOS.
877
+ Only available on Android, iOS and Electron.
845
878
 
846
879
  **Since:** 5.0.0
847
880
 
@@ -858,7 +891,7 @@ Reset the app to the default bundle.
858
891
 
859
892
  Call `reload()` or restart the app to apply the changes.
860
893
 
861
- Only available on Android and iOS.
894
+ Only available on Android, iOS and Electron.
862
895
 
863
896
  **Since:** 5.0.0
864
897
 
@@ -876,7 +909,7 @@ Reset the runtime configuration to the values from the Capacitor config file.
876
909
  This clears any runtime configuration set via `setConfig()`.
877
910
  The changes take effect immediately.
878
911
 
879
- Only available on Android and iOS.
912
+ Only available on Android, iOS and Electron.
880
913
 
881
914
  **Since:** 7.4.0
882
915
 
@@ -891,7 +924,7 @@ setChannel(options: SetChannelOptions) => Promise<void>
891
924
 
892
925
  Set the channel to use for the update.
893
926
 
894
- Only available on Android and iOS.
927
+ Only available on Android, iOS and Electron.
895
928
 
896
929
  | Param | Type |
897
930
  | ------------- | --------------------------------------------------------------- |
@@ -917,7 +950,7 @@ The changes are persisted across app restarts and take effect immediately.
917
950
  whenever the native app is updated to a new version. This ensures that
918
951
  configuration from previous versions doesn't persist after an app update.
919
952
 
920
- Only available on Android and iOS.
953
+ Only available on Android, iOS and Electron.
921
954
 
922
955
  | Param | Type |
923
956
  | ------------- | ------------------------------------------------------------- |
@@ -936,7 +969,7 @@ setCustomId(options: SetCustomIdOptions) => Promise<void>
936
969
 
937
970
  Set the custom identifier of the device.
938
971
 
939
- Only available on Android and iOS.
972
+ Only available on Android, iOS and Electron.
940
973
 
941
974
  | Param | Type |
942
975
  | ------------- | ----------------------------------------------------------------- |
@@ -957,7 +990,7 @@ Set the next bundle to use for the app.
957
990
 
958
991
  Call `reload()` or restart the app to apply the changes.
959
992
 
960
- Only available on Android and iOS.
993
+ Only available on Android, iOS and Electron.
961
994
 
962
995
  | Param | Type |
963
996
  | ------------- | --------------------------------------------------------------------- |
@@ -978,7 +1011,7 @@ Automatically download and set the latest bundle for the app using the [Capaweso
978
1011
 
979
1012
  Call `reload()` or restart the app to apply the changes.
980
1013
 
981
- Only available on Android and iOS.
1014
+ Only available on Android, iOS and Electron.
982
1015
 
983
1016
  | Param | Type |
984
1017
  | ------------- | --------------------------------------------------- |
@@ -999,7 +1032,7 @@ addListener(eventName: 'downloadBundleProgress', listenerFunc: DownloadBundlePro
999
1032
 
1000
1033
  Listen for the download progress of a bundle.
1001
1034
 
1002
- Only available on Android and iOS.
1035
+ Only available on Android, iOS and Electron.
1003
1036
 
1004
1037
  | Param | Type |
1005
1038
  | ------------------ | ----------------------------------------------------------------------------------------- |
@@ -1024,7 +1057,7 @@ Listen for when a bundle is set as the next bundle.
1024
1057
  This event is triggered whenever a bundle is set to be used on the next app restart,
1025
1058
  either through automatic updates or manual calls to `setNextBundle()`.
1026
1059
 
1027
- Only available on Android and iOS.
1060
+ Only available on Android, iOS and Electron.
1028
1061
 
1029
1062
  | Param | Type |
1030
1063
  | ------------------ | ----------------------------------------------------------------------- |
@@ -1053,7 +1086,7 @@ and the app has been reloaded.
1053
1086
  use the `ready()` method instead. The `ready()` method provides detailed information
1054
1087
  about the current bundle, previous bundle, and whether a rollback occurred.
1055
1088
 
1056
- Only available on Android and iOS.
1089
+ Only available on Android, iOS and Electron.
1057
1090
 
1058
1091
  | Param | Type |
1059
1092
  | ------------------ | ------------------------------------------------------------- |
@@ -1094,7 +1127,7 @@ Remove all listeners for this plugin.
1094
1127
 
1095
1128
  | Prop | Type | Description | Default | Since |
1096
1129
  | ------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ | ----- |
1097
- | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. | <code>'zip'</code> | 6.6.0 |
1130
+ | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. On **Electron**, only the `zip` artifact type is supported. | <code>'zip'</code> | 6.6.0 |
1098
1131
  | **`bundleId`** | <code>string</code> | The unique identifier of the bundle. **Attention**: The value `public` is reserved and cannot be used as a bundle identifier. | | 5.0.0 |
1099
1132
  | **`checksum`** | <code>string</code> | The checksum of the self-hosted bundle as a SHA-256 hash in hex format to verify the integrity of the bundle. **Attention**: Only supported for the `zip` artifact type. | | 7.1.0 |
1100
1133
  | **`signature`** | <code>string</code> | The signature of the self-hosted bundle as a signed SHA-256 hash in base64 format to verify the integrity of the bundle. **Attention**: Only supported for the `zip` artifact type. | | 7.1.0 |
@@ -1129,7 +1162,7 @@ Remove all listeners for this plugin.
1129
1162
 
1130
1163
  | Prop | Type | Description | Since |
1131
1164
  | ---------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1132
- | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. | 6.7.0 |
1165
+ | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. On **Electron**, only the `zip` artifact type is supported. | 6.7.0 |
1133
1166
  | **`bundleId`** | <code>string \| null</code> | The unique identifier of the latest bundle. On Capawesome Cloud, this is the ID of the app build artifact. If `null`, no bundle is available. | 6.6.0 |
1134
1167
  | **`channel`** | <code>string</code> | The name of the channel that the bundle is actually from. This is the resolved channel after applying any forced channel assignment and may differ from the channel set by the Live Update SDK. | 8.3.0 |
1135
1168
  | **`checksum`** | <code>string</code> | The checksum of the latest bundle if the bundle is self-hosted. If the bundle is hosted on Capawesome Cloud, the checksum will be returned as response header when downloading the bundle. | 7.1.0 |
@@ -1197,9 +1230,9 @@ Remove all listeners for this plugin.
1197
1230
 
1198
1231
  #### GetDeviceIdResult
1199
1232
 
1200
- | Prop | Type | Description | Since |
1201
- | -------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----- |
1202
- | **`deviceId`** | <code>string</code> | The unique identifier of the device. On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used. The value of this property is the same for apps that come from the same vendor running on the same device. | 5.0.0 |
1233
+ | Prop | Type | Description | Since |
1234
+ | -------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1235
+ | **`deviceId`** | <code>string</code> | The unique identifier of the device. On iOS, [`identifierForVendor`](https://developer.apple.com/documentation/uikit/uidevice/1620059-identifierforvendor) is used. The value of this property is the same for apps that come from the same vendor running on the same device. On Electron, a random UUID is generated on first use and stored in the app's user data directory. The value changes when the user data is cleared. | 5.0.0 |
1203
1236
 
1204
1237
 
1205
1238
  #### IsSyncingResult
@@ -1218,16 +1251,16 @@ Remove all listeners for this plugin.
1218
1251
 
1219
1252
  #### GetVersionCodeResult
1220
1253
 
1221
- | Prop | Type | Description | Since |
1222
- | ----------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1223
- | **`versionCode`** | <code>string</code> | The version code of the app. On **Android**, this is the `versionCode` from the `android/app/build.gradle` file. On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file. | 5.0.0 |
1254
+ | Prop | Type | Description | Since |
1255
+ | ----------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1256
+ | **`versionCode`** | <code>string</code> | The version code of the app. On **Android**, this is the `versionCode` from the `android/app/build.gradle` file. On **iOS**, this is the `CFBundleVersion` from the `Info.plist` file. On **Electron**, this is the `version` from the `electron/package.json` file. | 5.0.0 |
1224
1257
 
1225
1258
 
1226
1259
  #### GetVersionNameResult
1227
1260
 
1228
- | Prop | Type | Description | Since |
1229
- | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1230
- | **`versionName`** | <code>string</code> | The version name of the app. On **Android**, this is the `versionName` from the `android/app/build.gradle` file. On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file. | 5.0.0 |
1261
+ | Prop | Type | Description | Since |
1262
+ | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- |
1263
+ | **`versionName`** | <code>string</code> | The version name of the app. On **Android**, this is the `versionName` from the `android/app/build.gradle` file. On **iOS**, this is the `CFBundleShortVersionString` from the `Info.plist` file. On **Electron**, this is the `version` from the `electron/package.json` file. | 5.0.0 |
1231
1264
 
1232
1265
 
1233
1266
  #### ReadyResult
@@ -57,6 +57,7 @@ import java.io.FileInputStream;
57
57
  import java.io.FileOutputStream;
58
58
  import java.io.IOException;
59
59
  import java.io.InputStream;
60
+ import java.net.SocketTimeoutException;
60
61
  import java.security.KeyFactory;
61
62
  import java.security.MessageDigest;
62
63
  import java.security.PublicKey;
@@ -180,7 +181,7 @@ public class LiveUpdate {
180
181
  .host(config.getServerDomain())
181
182
  .addPathSegment("v1")
182
183
  .addPathSegment("apps")
183
- .addPathSegment(getAppId())
184
+ .addPathSegment(requireAppId())
184
185
  .addPathSegment("channels");
185
186
  if (options.getLimit() != null) {
186
187
  urlBuilder.addQueryParameter("limit", String.valueOf(options.getLimit()));
@@ -739,6 +740,8 @@ public class LiveUpdate {
739
740
  Logger.error(LiveUpdatePlugin.TAG, errorMessage, exception);
740
741
  completionCallback.error(exception);
741
742
  }
743
+ } catch (IOException e) {
744
+ handleDownloadFailure(e, completionCallback);
742
745
  } catch (Exception e) {
743
746
  completionCallback.error(e);
744
747
  }
@@ -746,7 +749,7 @@ public class LiveUpdate {
746
749
 
747
750
  @Override
748
751
  public void error(@NonNull Exception exception) {
749
- completionCallback.error(exception);
752
+ handleDownloadFailure(exception, completionCallback);
750
753
  }
751
754
  }
752
755
  );
@@ -1006,7 +1009,7 @@ public class LiveUpdate {
1006
1009
  .host(config.getServerDomain())
1007
1010
  .addPathSegment("v1")
1008
1011
  .addPathSegment("apps")
1009
- .addPathSegment(getAppId())
1012
+ .addPathSegment(requireAppId())
1010
1013
  .addPathSegment("bundles")
1011
1014
  .addPathSegment("latest")
1012
1015
  .addQueryParameter("appVersionCode", getVersionCodeAsString())
@@ -1207,6 +1210,15 @@ public class LiveUpdate {
1207
1210
  return getPackageInfo().versionName;
1208
1211
  }
1209
1212
 
1213
+ private void handleDownloadFailure(@NonNull Exception exception, @NonNull EmptyCallback callback) {
1214
+ Logger.error(LiveUpdatePlugin.TAG, exception.getMessage(), exception);
1215
+ if (exception instanceof SocketTimeoutException) {
1216
+ callback.error(exception);
1217
+ } else {
1218
+ callback.error(new Exception(LiveUpdatePlugin.ERROR_DOWNLOAD_FAILED));
1219
+ }
1220
+ }
1221
+
1210
1222
  private boolean hasBundleById(@NonNull String bundleId) {
1211
1223
  File bundleDirectory = buildBundleDirectoryFor(bundleId);
1212
1224
  return bundleDirectory.exists();
@@ -1285,6 +1297,15 @@ public class LiveUpdate {
1285
1297
  sync(options, callback);
1286
1298
  }
1287
1299
 
1300
+ @NonNull
1301
+ private String requireAppId() throws Exception {
1302
+ String appId = getAppId();
1303
+ if (appId == null || appId.isEmpty()) {
1304
+ throw new Exception(LiveUpdatePlugin.ERROR_APP_ID_MISSING);
1305
+ }
1306
+ return appId;
1307
+ }
1308
+
1288
1309
  private void rollback() {
1289
1310
  // Set the rollback flag
1290
1311
  rollbackPerformed = true;
@@ -88,7 +88,7 @@ public class LiveUpdateHttpClient {
88
88
 
89
89
  @Override
90
90
  public void onFailure(@NonNull Call call, @NonNull IOException e) {
91
- callback.error(new Exception(e));
91
+ callback.error(e);
92
92
  }
93
93
  }
94
94
  );
@@ -37,7 +37,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
37
37
  public class LiveUpdatePlugin extends Plugin {
38
38
 
39
39
  public static final String TAG = "LiveUpdate";
40
- public static final String VERSION = "8.4.3";
40
+ public static final String VERSION = "8.5.0";
41
41
  public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
42
42
  public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
43
43
  public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
@@ -60,9 +60,6 @@ public class LiveUpdatePlugin extends Plugin {
60
60
  public static final String EVENT_NEXT_BUNDLE_SET = "nextBundleSet";
61
61
  public static final String EVENT_RELOADED = "reloaded";
62
62
 
63
- @Nullable
64
- private LiveUpdateConfig config;
65
-
66
63
  @Nullable
67
64
  private LiveUpdate implementation;
68
65
 
@@ -70,8 +67,7 @@ public class LiveUpdatePlugin extends Plugin {
70
67
 
71
68
  public void load() {
72
69
  try {
73
- config = getLiveUpdateConfig();
74
- implementation = new LiveUpdate(config, this);
70
+ implementation = new LiveUpdate(getLiveUpdateConfig(), this);
75
71
  } catch (Exception exception) {
76
72
  Logger.error(TAG, exception.getMessage(), exception);
77
73
  }
@@ -183,12 +179,6 @@ public class LiveUpdatePlugin extends Plugin {
183
179
  @PluginMethod
184
180
  public void fetchChannels(PluginCall call) {
185
181
  try {
186
- String appId = config.getAppId();
187
- if (appId == null || appId.isEmpty()) {
188
- call.reject(ERROR_APP_ID_MISSING);
189
- return;
190
- }
191
-
192
182
  FetchChannelsOptions options = new FetchChannelsOptions(call);
193
183
  NonEmptyCallback<FetchChannelsResult> callback = new NonEmptyCallback<>() {
194
184
  @Override
@@ -211,12 +201,6 @@ public class LiveUpdatePlugin extends Plugin {
211
201
  @PluginMethod
212
202
  public void fetchLatestBundle(PluginCall call) {
213
203
  try {
214
- String appId = config.getAppId();
215
- if (appId == null || appId.isEmpty()) {
216
- call.reject(ERROR_APP_ID_MISSING);
217
- return;
218
- }
219
-
220
204
  FetchLatestBundleOptions options = new FetchLatestBundleOptions(call);
221
205
  NonEmptyCallback<FetchLatestBundleResult> callback = new NonEmptyCallback<>() {
222
206
  @Override
@@ -633,12 +617,6 @@ public class LiveUpdatePlugin extends Plugin {
633
617
  @PluginMethod
634
618
  public void sync(PluginCall call) {
635
619
  try {
636
- String appId = config.getAppId();
637
- if (appId == null || appId.isEmpty()) {
638
- call.reject(ERROR_APP_ID_MISSING);
639
- return;
640
- }
641
-
642
620
  SyncOptions options = new SyncOptions(call);
643
621
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
644
622
  @Override