@capawesome/capacitor-live-update 6.5.0 → 6.7.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.
Files changed (32) hide show
  1. package/README.md +184 -37
  2. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +63 -5
  3. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +98 -3
  4. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +3 -0
  5. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +15 -1
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/FetchLatestBundleOptions.java +24 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetNextBundleOptions.java +20 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +20 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +41 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetCurrentBundleResult.java +22 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetNextBundleResult.java +22 -0
  12. package/dist/docs.json +318 -18
  13. package/dist/esm/definitions.d.ts +159 -14
  14. package/dist/esm/definitions.js.map +1 -1
  15. package/dist/esm/web.d.ts +5 -1
  16. package/dist/esm/web.js +12 -0
  17. package/dist/esm/web.js.map +1 -1
  18. package/dist/plugin.cjs.js +12 -0
  19. package/dist/plugin.cjs.js.map +1 -1
  20. package/dist/plugin.js +12 -0
  21. package/dist/plugin.js.map +1 -1
  22. package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +11 -1
  23. package/ios/Plugin/Classes/Options/FetchLatestBundleOptions.swift +18 -0
  24. package/ios/Plugin/Classes/Options/SetNextBundleOptions.swift +14 -0
  25. package/ios/Plugin/Classes/Options/SyncOptions.swift +14 -0
  26. package/ios/Plugin/Classes/Results/FetchLatestBundle.swift +28 -0
  27. package/ios/Plugin/Classes/Results/GetCurrentBundleResult.swift +16 -0
  28. package/ios/Plugin/Classes/Results/GetNextBundleResult.swift +16 -0
  29. package/ios/Plugin/LiveUpdate.swift +55 -6
  30. package/ios/Plugin/LiveUpdatePlugin.m +5 -1
  31. package/ios/Plugin/LiveUpdatePlugin.swift +79 -20
  32. package/package.json +2 -2
package/README.md CHANGED
@@ -103,7 +103,7 @@ In `capacitor.config.json`:
103
103
  In `capacitor.config.ts`:
104
104
 
105
105
  ```ts
106
- /// <reference types="@capacitor/live-update" />
106
+ /// <reference types="@capawesome/capacitor-live-update" />
107
107
 
108
108
  import { CapacitorConfig } from '@capacitor/cli';
109
109
 
@@ -128,10 +128,6 @@ export default config;
128
128
 
129
129
  </docgen-config>
130
130
 
131
- ## Demo
132
-
133
- A working example can be found here: [robingenz/capacitor-plugin-demo](https://github.com/robingenz/capacitor-plugin-demo)
134
-
135
131
  ## Starter templates
136
132
 
137
133
  The following starter templates are available:
@@ -156,9 +152,8 @@ const downloadBundle = async () => {
156
152
  await LiveUpdate.downloadBundle({ url: 'https://example.com/1.0.0.zip', bundleId: '1.0.0' });
157
153
  };
158
154
 
159
- const getBundle = async () => {
160
- const result = await LiveUpdate.getBundle();
161
- return result.bundleId;
155
+ const fetchLatestBundle = async () => {
156
+ await LiveUpdate.fetchLatestBundle();
162
157
  };
163
158
 
164
159
  const getBundles = async () => {
@@ -171,6 +166,11 @@ const getChannel = async () => {
171
166
  return result.channel;
172
167
  };
173
168
 
169
+ const getCurrentBundle = async () => {
170
+ const result = await LiveUpdate.getCurrentBundle();
171
+ return result.bundleId;
172
+ };
173
+
174
174
  const getCustomId = async () => {
175
175
  const result = await LiveUpdate.getCustomId();
176
176
  return result.customId;
@@ -181,6 +181,11 @@ const getDeviceId = async () => {
181
181
  return result.deviceId;
182
182
  };
183
183
 
184
+ const getNextBundle = async () => {
185
+ const result = await LiveUpdate.getNextBundle();
186
+ return result.bundleId;
187
+ };
188
+
184
189
  const getVersionCode = async () => {
185
190
  const result = await LiveUpdate.getVersionCode();
186
191
  return result.versionCode;
@@ -203,10 +208,6 @@ const reset = async () => {
203
208
  await LiveUpdate.reset();
204
209
  };
205
210
 
206
- const setBundle = async () => {
207
- await LiveUpdate.setBundle({ bundleId: '1.0.0' });
208
- };
209
-
210
211
  const setChannel = async () => {
211
212
  await LiveUpdate.setChannel({ channel: 'beta' });
212
213
  };
@@ -215,10 +216,24 @@ const setCustomId = async () => {
215
216
  await LiveUpdate.setCustomId({ customId: 'my-custom-id' });
216
217
  };
217
218
 
219
+ const setNextBundle = async () => {
220
+ await LiveUpdate.setNextBundle({ bundleId: '1.0.0' });
221
+ };
222
+
218
223
  const sync = async () => {
219
224
  const result = await LiveUpdate.sync();
220
225
  return result.nextBundleId;
221
226
  };
227
+
228
+ const isNewBundleAvailable = async () => {
229
+ const { bundleId: latestBundleId } = await LiveUpdate.fetchLatestBundle();
230
+ if (latestBundleId) {
231
+ const { bundleId: currentBundleId } = await LiveUpdate.getBundle();
232
+ return latestBundleId !== currentBundleId;
233
+ } else {
234
+ return false;
235
+ }
236
+ };
222
237
  ```
223
238
 
224
239
  ## API
@@ -227,11 +242,14 @@ const sync = async () => {
227
242
 
228
243
  * [`deleteBundle(...)`](#deletebundle)
229
244
  * [`downloadBundle(...)`](#downloadbundle)
245
+ * [`fetchLatestBundle(...)`](#fetchlatestbundle)
230
246
  * [`getBundle()`](#getbundle)
231
247
  * [`getBundles()`](#getbundles)
232
248
  * [`getChannel()`](#getchannel)
249
+ * [`getCurrentBundle()`](#getcurrentbundle)
233
250
  * [`getCustomId()`](#getcustomid)
234
251
  * [`getDeviceId()`](#getdeviceid)
252
+ * [`getNextBundle()`](#getnextbundle)
235
253
  * [`getVersionCode()`](#getversioncode)
236
254
  * [`getVersionName()`](#getversionname)
237
255
  * [`ready()`](#ready)
@@ -240,7 +258,8 @@ const sync = async () => {
240
258
  * [`setBundle(...)`](#setbundle)
241
259
  * [`setChannel(...)`](#setchannel)
242
260
  * [`setCustomId(...)`](#setcustomid)
243
- * [`sync()`](#sync)
261
+ * [`setNextBundle(...)`](#setnextbundle)
262
+ * [`sync(...)`](#sync)
244
263
  * [Interfaces](#interfaces)
245
264
 
246
265
  </docgen-index>
@@ -286,6 +305,27 @@ Only available on Android and iOS.
286
305
  --------------------
287
306
 
288
307
 
308
+ ### fetchLatestBundle(...)
309
+
310
+ ```typescript
311
+ fetchLatestBundle(options?: FetchLatestBundleOptions | undefined) => Promise<FetchLatestBundleResult>
312
+ ```
313
+
314
+ Fetch the latest bundle using the [Capawesome Cloud](https://capawesome.io/cloud/).
315
+
316
+ Only available on Android and iOS.
317
+
318
+ | Param | Type |
319
+ | ------------- | ----------------------------------------------------------------------------- |
320
+ | **`options`** | <code><a href="#fetchlatestbundleoptions">FetchLatestBundleOptions</a></code> |
321
+
322
+ **Returns:** <code>Promise&lt;<a href="#fetchlatestbundleresult">FetchLatestBundleResult</a>&gt;</code>
323
+
324
+ **Since:** 6.6.0
325
+
326
+ --------------------
327
+
328
+
289
329
  ### getBundle()
290
330
 
291
331
  ```typescript
@@ -326,7 +366,7 @@ Only available on Android and iOS.
326
366
  getChannel() => Promise<GetChannelResult>
327
367
  ```
328
368
 
329
- Get the channel of the app.
369
+ Get the channel that is used for the update.
330
370
 
331
371
  Only available on Android and iOS.
332
372
 
@@ -337,13 +377,31 @@ Only available on Android and iOS.
337
377
  --------------------
338
378
 
339
379
 
380
+ ### getCurrentBundle()
381
+
382
+ ```typescript
383
+ getCurrentBundle() => Promise<GetCurrentBundleResult>
384
+ ```
385
+
386
+ Get the bundle identifier of the current bundle.
387
+ The current bundle is the bundle that is currently used by the app.
388
+
389
+ Only available on Android and iOS.
390
+
391
+ **Returns:** <code>Promise&lt;<a href="#getcurrentbundleresult">GetCurrentBundleResult</a>&gt;</code>
392
+
393
+ **Since:** 6.7.0
394
+
395
+ --------------------
396
+
397
+
340
398
  ### getCustomId()
341
399
 
342
400
  ```typescript
343
401
  getCustomId() => Promise<GetCustomIdResult>
344
402
  ```
345
403
 
346
- Get the custom identifier of the app.
404
+ Get the custom identifier of the device.
347
405
 
348
406
  Only available on Android and iOS.
349
407
 
@@ -360,7 +418,7 @@ Only available on Android and iOS.
360
418
  getDeviceId() => Promise<GetDeviceIdResult>
361
419
  ```
362
420
 
363
- Get the device identifier of the app.
421
+ Get the unique device identifier.
364
422
 
365
423
  Only available on Android and iOS.
366
424
 
@@ -371,6 +429,25 @@ Only available on Android and iOS.
371
429
  --------------------
372
430
 
373
431
 
432
+ ### getNextBundle()
433
+
434
+ ```typescript
435
+ getNextBundle() => Promise<GetNextBundleResult>
436
+ ```
437
+
438
+ Get the bundle identifier of the next bundle.
439
+ The next bundle is the bundle that will be used after calling `reload()`
440
+ or restarting the app.
441
+
442
+ Only available on Android and iOS.
443
+
444
+ **Returns:** <code>Promise&lt;<a href="#getnextbundleresult">GetNextBundleResult</a>&gt;</code>
445
+
446
+ **Since:** 6.7.0
447
+
448
+ --------------------
449
+
450
+
374
451
  ### getVersionCode()
375
452
 
376
453
  ```typescript
@@ -482,7 +559,7 @@ Only available on Android and iOS.
482
559
  setChannel(options: SetChannelOptions) => Promise<void>
483
560
  ```
484
561
 
485
- Set the channel of the app.
562
+ Set the channel to use for the update.
486
563
 
487
564
  Only available on Android and iOS.
488
565
 
@@ -501,7 +578,7 @@ Only available on Android and iOS.
501
578
  setCustomId(options: SetCustomIdOptions) => Promise<void>
502
579
  ```
503
580
 
504
- Set the custom identifier of the app.
581
+ Set the custom identifier of the device.
505
582
 
506
583
  Only available on Android and iOS.
507
584
 
@@ -514,10 +591,31 @@ Only available on Android and iOS.
514
591
  --------------------
515
592
 
516
593
 
517
- ### sync()
594
+ ### setNextBundle(...)
518
595
 
519
596
  ```typescript
520
- sync() => Promise<SyncResult>
597
+ setNextBundle(options: SetNextBundleOptions) => Promise<void>
598
+ ```
599
+
600
+ Set the next bundle to use for the app.
601
+
602
+ Call `reload()` or restart the app to apply the changes.
603
+
604
+ Only available on Android and iOS.
605
+
606
+ | Param | Type |
607
+ | ------------- | --------------------------------------------------------------------- |
608
+ | **`options`** | <code><a href="#setnextbundleoptions">SetNextBundleOptions</a></code> |
609
+
610
+ **Since:** 6.7.0
611
+
612
+ --------------------
613
+
614
+
615
+ ### sync(...)
616
+
617
+ ```typescript
618
+ sync(options?: SyncOptions | undefined) => Promise<SyncResult>
521
619
  ```
522
620
 
523
621
  Automatically download and set the latest bundle for the app using the [Capawesome Cloud](https://capawesome.io/cloud/).
@@ -526,6 +624,10 @@ Call `reload()` or restart the app to apply the changes.
526
624
 
527
625
  Only available on Android and iOS.
528
626
 
627
+ | Param | Type |
628
+ | ------------- | --------------------------------------------------- |
629
+ | **`options`** | <code><a href="#syncoptions">SyncOptions</a></code> |
630
+
529
631
  **Returns:** <code>Promise&lt;<a href="#syncresult">SyncResult</a>&gt;</code>
530
632
 
531
633
  **Since:** 5.0.0
@@ -545,11 +647,28 @@ Only available on Android and iOS.
545
647
 
546
648
  #### DownloadBundleOptions
547
649
 
548
- | Prop | Type | Description | Since |
549
- | -------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------- | ----- |
550
- | **`bundleId`** | <code>string</code> | The unique identifier of the bundle. | 5.0.0 |
551
- | **`checksum`** | <code>string</code> | The checksum of the bundle to verify the integrity of the ZIP file. Must be a SHA-256 hash in hexadecimal format. | 6.1.0 |
552
- | **`url`** | <code>string</code> | The URL of the bundle to download. The bundle must be a ZIP file containing at least a `index.html` file. | 5.0.0 |
650
+ | Prop | Type | Description | Default | Since |
651
+ | ------------------ | -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ----- |
652
+ | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. | <code>'zip'</code> | 6.6.0 |
653
+ | **`bundleId`** | <code>string</code> | The unique identifier of the bundle. | | 5.0.0 |
654
+ | **`checksum`** | <code>string</code> | The checksum of the bundle to verify the integrity of the ZIP file. Must be a SHA-256 hash in base64 format. | | 6.1.0 |
655
+ | **`url`** | <code>string</code> | The URL of the bundle to download. For the `zip` artifact type, the URL must point to a ZIP file. For the `manifest` artifact type, the URL serves as the base URL to download the individual files. For example, if the URL is `https://example.com/download`, the plugin will download the file with the href `index.html` from `https://example.com/download?href=index.html`. To **verify the integrity** of the file, the server must return a `X-Checksum` header with the SHA-256 hash in base64 format. To **verify the signature** of the file, the server must return a `X-Signature` header with the signed SHA-256 hash in base64 format. | | 5.0.0 |
656
+
657
+
658
+ #### FetchLatestBundleResult
659
+
660
+ | Prop | Type | Description | Since |
661
+ | ------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ----- |
662
+ | **`artifactType`** | <code>'manifest' \| 'zip'</code> | The artifact type of the bundle. | 6.7.0 |
663
+ | **`bundleId`** | <code>string \| null</code> | The unique identifier of the latest bundle. If `null`, no bundle is available. | 6.6.0 |
664
+ | **`downloadUrl`** | <code>string</code> | The URL of the latest bundle to download. Pass this URL to the `downloadBundle(...)` method to download the bundle. | 6.7.0 |
665
+
666
+
667
+ #### FetchLatestBundleOptions
668
+
669
+ | Prop | Type | Description | Since |
670
+ | ------------- | ------------------- | ---------------------------------------------------------------- | ----- |
671
+ | **`channel`** | <code>string</code> | The name of the channel where the latest bundle is fetched from. | 6.7.0 |
553
672
 
554
673
 
555
674
  #### GetBundleResult
@@ -568,16 +687,23 @@ Only available on Android and iOS.
568
687
 
569
688
  #### GetChannelResult
570
689
 
571
- | Prop | Type | Description | Since |
572
- | ------------- | --------------------------- | ------------------------------------------------------------------------ | ----- |
573
- | **`channel`** | <code>string \| null</code> | The channel of the app. If `null`, the app is using the default channel. | 5.0.0 |
690
+ | Prop | Type | Description | Since |
691
+ | ------------- | --------------------------- | ------------------------------------------------------------------ | ----- |
692
+ | **`channel`** | <code>string \| null</code> | The channel name. If `null`, the app is using the default channel. | 5.0.0 |
693
+
694
+
695
+ #### GetCurrentBundleResult
696
+
697
+ | Prop | Type | Description | Since |
698
+ | -------------- | --------------------------- | ----------------------------------------------------------------------------------------- | ----- |
699
+ | **`bundleId`** | <code>string \| null</code> | The unique identifier of the current bundle. If `null`, the default bundle is being used. | 6.7.0 |
574
700
 
575
701
 
576
702
  #### GetCustomIdResult
577
703
 
578
- | Prop | Type | Description | Since |
579
- | -------------- | --------------------------- | ------------------------------------------------------------------------- | ----- |
580
- | **`customId`** | <code>string \| null</code> | The custom identifier of the app. If `null`, no custom identifier is set. | 5.0.0 |
704
+ | Prop | Type | Description | Since |
705
+ | -------------- | --------------------------- | ---------------------------------------------------------------------------- | ----- |
706
+ | **`customId`** | <code>string \| null</code> | The custom identifier of the device. If `null`, no custom identifier is set. | 5.0.0 |
581
707
 
582
708
 
583
709
  #### GetDeviceIdResult
@@ -587,6 +713,13 @@ Only available on Android and iOS.
587
713
  | **`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 |
588
714
 
589
715
 
716
+ #### GetNextBundleResult
717
+
718
+ | Prop | Type | Description | Since |
719
+ | -------------- | --------------------------- | -------------------------------------------------------------------------------------- | ----- |
720
+ | **`bundleId`** | <code>string \| null</code> | The unique identifier of the next bundle. If `null`, the default bundle is being used. | 6.7.0 |
721
+
722
+
590
723
  #### GetVersionCodeResult
591
724
 
592
725
  | Prop | Type | Description | Since |
@@ -610,16 +743,23 @@ Only available on Android and iOS.
610
743
 
611
744
  #### SetChannelOptions
612
745
 
613
- | Prop | Type | Description | Since |
614
- | ------------- | --------------------------- | --------------------------------------------------------- | ----- |
615
- | **`channel`** | <code>string \| null</code> | The channel of the app. Set `null` to remove the channel. | 5.0.0 |
746
+ | Prop | Type | Description | Since |
747
+ | ------------- | --------------------------- | --------------------------------------------------- | ----- |
748
+ | **`channel`** | <code>string \| null</code> | The channel name. Set `null` to remove the channel. | 5.0.0 |
616
749
 
617
750
 
618
751
  #### SetCustomIdOptions
619
752
 
620
- | Prop | Type | Description | Since |
621
- | -------------- | --------------------------- | ----------------------------------------------------------------------------- | ----- |
622
- | **`customId`** | <code>string \| null</code> | The custom identifier of the app. Set `null` to remove the custom identifier. | 5.0.0 |
753
+ | Prop | Type | Description | Since |
754
+ | -------------- | --------------------------- | -------------------------------------------------------------------------------- | ----- |
755
+ | **`customId`** | <code>string \| null</code> | The custom identifier of the device. Set `null` to remove the custom identifier. | 5.0.0 |
756
+
757
+
758
+ #### SetNextBundleOptions
759
+
760
+ | Prop | Type | Description | Since |
761
+ | -------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------- | ----- |
762
+ | **`bundleId`** | <code>string \| null</code> | The unique identifier of the bundle to use. Set `null` to use the default bundle (same as calling `reset()`). | 6.7.0 |
623
763
 
624
764
 
625
765
  #### SyncResult
@@ -628,6 +768,13 @@ Only available on Android and iOS.
628
768
  | ------------------ | --------------------------- | ---------------------------------------------------------------------------------------------------------- | ----- |
629
769
  | **`nextBundleId`** | <code>string \| null</code> | The identifier of the next bundle to use. If `null`, the app is up-to-date and no new bundle is available. | 5.0.0 |
630
770
 
771
+
772
+ #### SyncOptions
773
+
774
+ | Prop | Type | Description | Since |
775
+ | ------------- | ------------------- | ---------------------------------------------------------------- | ----- |
776
+ | **`channel`** | <code>string</code> | The name of the channel where the latest bundle is fetched from. | 6.7.0 |
777
+
631
778
  </docgen-api>
632
779
 
633
780
  ## Testing
@@ -17,14 +17,20 @@ import io.capawesome.capacitorjs.plugins.liveupdate.classes.ManifestItem;
17
17
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.api.GetLatestBundleResponse;
18
18
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DeleteBundleOptions;
19
19
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DownloadBundleOptions;
20
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.FetchLatestBundleOptions;
20
21
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetBundleOptions;
21
22
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetChannelOptions;
22
23
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetCustomIdOptions;
24
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetNextBundleOptions;
25
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SyncOptions;
26
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.FetchLatestBundleResult;
23
27
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetBundleResult;
24
28
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetBundlesResult;
25
29
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetChannelResult;
30
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetCurrentBundleResult;
26
31
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetCustomIdResult;
27
32
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetDeviceIdResult;
33
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetNextBundleResult;
28
34
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetVersionCodeResult;
29
35
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.GetVersionNameResult;
30
36
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.results.SyncResult;
@@ -120,6 +126,7 @@ public class LiveUpdate {
120
126
  }
121
127
 
122
128
  public void downloadBundle(@NonNull DownloadBundleOptions options, @NonNull EmptyCallback callback) throws Exception {
129
+ ArtifactType artifactType = options.getArtifactType();
123
130
  String bundleId = options.getBundleId();
124
131
  String checksum = options.getChecksum();
125
132
  String url = options.getUrl();
@@ -132,10 +139,23 @@ public class LiveUpdate {
132
139
  }
133
140
 
134
141
  // Download the bundle
135
- downloadBundleOfTypeZip(bundleId, url, checksum);
142
+ if (artifactType == ArtifactType.MANIFEST) {
143
+ downloadBundleOfTypeManifest(bundleId, url);
144
+ } else {
145
+ downloadBundleOfTypeZip(bundleId, url, checksum);
146
+ }
136
147
  callback.success();
137
148
  }
138
149
 
150
+ public void fetchLatestBundle(@NonNull FetchLatestBundleOptions options, @NonNull NonEmptyCallback callback) throws Exception {
151
+ GetLatestBundleResponse response = fetchLatestBundle(options);
152
+ ArtifactType artifactType = response == null ? null : response.getArtifactType();
153
+ String bundleId = response == null ? null : response.getBundleId();
154
+ String downloadUrl = response == null ? null : response.getUrl();
155
+ FetchLatestBundleResult result = new FetchLatestBundleResult(artifactType, bundleId, downloadUrl);
156
+ callback.success(result);
157
+ }
158
+
139
159
  public void getBundle(@NonNull NonEmptyCallback callback) {
140
160
  String bundleId = getCurrentBundleId();
141
161
  if (bundleId.equals(defaultWebAssetDir)) {
@@ -157,6 +177,15 @@ public class LiveUpdate {
157
177
  callback.success(result);
158
178
  }
159
179
 
180
+ public void getCurrentBundle(@NonNull NonEmptyCallback<GetCurrentBundleResult> callback) {
181
+ String bundleId = getCurrentBundleId();
182
+ if (bundleId.equals(defaultWebAssetDir)) {
183
+ bundleId = null;
184
+ }
185
+ GetCurrentBundleResult result = new GetCurrentBundleResult(bundleId);
186
+ callback.success(result);
187
+ }
188
+
160
189
  public void getCustomId(@NonNull NonEmptyCallback callback) {
161
190
  String customId = preferences.getCustomId();
162
191
  GetCustomIdResult result = new GetCustomIdResult(customId);
@@ -169,6 +198,15 @@ public class LiveUpdate {
169
198
  callback.success(result);
170
199
  }
171
200
 
201
+ public void getNextBundle(@NonNull NonEmptyCallback<GetNextBundleResult> callback) {
202
+ String bundleId = getNextBundleId();
203
+ if (bundleId.equals(defaultWebAssetDir)) {
204
+ bundleId = null;
205
+ }
206
+ GetNextBundleResult result = new GetNextBundleResult(bundleId);
207
+ callback.success(result);
208
+ }
209
+
172
210
  public void getVersionCode(@NonNull NonEmptyCallback callback) throws PackageManager.NameNotFoundException {
173
211
  String versionCode = getVersionCode();
174
212
  GetVersionCodeResult result = new GetVersionCodeResult(versionCode);
@@ -228,9 +266,28 @@ public class LiveUpdate {
228
266
  callback.success();
229
267
  }
230
268
 
231
- public void sync(@NonNull NonEmptyCallback<Result> callback) throws Exception {
269
+ public void setNextBundle(@NonNull SetNextBundleOptions options, @NonNull EmptyCallback callback) {
270
+ String bundleId = options.getBundleId();
271
+
272
+ if (bundleId == null) {
273
+ reset();
274
+ } else {
275
+ if (hasBundle(bundleId)) {
276
+ setNextBundle(bundleId);
277
+ } else {
278
+ Exception exception = new Exception(LiveUpdatePlugin.ERROR_BUNDLE_NOT_FOUND);
279
+ callback.error(exception);
280
+ return;
281
+ }
282
+ }
283
+ callback.success();
284
+ }
285
+
286
+ public void sync(@NonNull SyncOptions options, @NonNull NonEmptyCallback<Result> callback) throws Exception {
287
+ String channel = options.getChannel();
232
288
  // Fetch the latest bundle
233
- GetLatestBundleResponse response = fetchLatestBundle();
289
+ FetchLatestBundleOptions fetchLatestBundleOptions = new FetchLatestBundleOptions(channel);
290
+ GetLatestBundleResponse response = fetchLatestBundle(fetchLatestBundleOptions);
234
291
  if (response == null) {
235
292
  Logger.debug(LiveUpdatePlugin.TAG, "No update available.");
236
293
  SyncResult syncResult = new SyncResult(null);
@@ -534,7 +591,8 @@ public class LiveUpdate {
534
591
  }
535
592
 
536
593
  @Nullable
537
- private GetLatestBundleResponse fetchLatestBundle() throws Exception {
594
+ private GetLatestBundleResponse fetchLatestBundle(@NonNull FetchLatestBundleOptions options) throws Exception {
595
+ String channel = options.getChannel() == null ? getChannel() : options.getChannel();
538
596
  String url = new HttpUrl.Builder()
539
597
  .scheme("https")
540
598
  .host(host)
@@ -546,7 +604,7 @@ public class LiveUpdate {
546
604
  .addQueryParameter("appVersionCode", getVersionCode())
547
605
  .addQueryParameter("appVersionName", getVersionName())
548
606
  .addQueryParameter("bundleId", getCurrentBundleId())
549
- .addQueryParameter("channelName", getChannel())
607
+ .addQueryParameter("channelName", channel)
550
608
  .addQueryParameter("customId", preferences.getCustomId())
551
609
  .addQueryParameter("deviceId", getDeviceId())
552
610
  .addQueryParameter("osVersion", String.valueOf(Build.VERSION.SDK_INT))