@capawesome/capacitor-live-update 6.7.1 → 7.0.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 (43) hide show
  1. package/CapawesomeCapacitorLiveUpdate.podspec +2 -2
  2. package/Package.swift +32 -0
  3. package/README.md +91 -81
  4. package/android/build.gradle +9 -9
  5. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +165 -132
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +6 -27
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +7 -2
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +50 -78
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +12 -5
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +9 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java +32 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +1 -10
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +13 -1
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/ReadyResult.java +32 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/DownloadProgressCallback.java +5 -0
  16. package/dist/docs.json +191 -158
  17. package/dist/esm/definitions.d.ts +107 -52
  18. package/dist/esm/definitions.js.map +1 -1
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/esm/web.d.ts +2 -2
  22. package/dist/esm/web.js.map +1 -1
  23. package/dist/plugin.cjs.js +1 -3
  24. package/dist/plugin.cjs.js.map +1 -1
  25. package/dist/plugin.js +1 -3
  26. package/dist/plugin.js.map +1 -1
  27. package/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift +25 -0
  28. package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +1 -7
  29. package/ios/Plugin/Classes/Results/{FetchLatestBundle.swift → FetchLatestBundleResult.swift} +6 -1
  30. package/ios/Plugin/Classes/Results/ReadyResult.swift +22 -0
  31. package/ios/Plugin/LiveUpdate.swift +167 -148
  32. package/ios/Plugin/LiveUpdateConfig.swift +2 -4
  33. package/ios/Plugin/LiveUpdateHttpClient.swift +6 -2
  34. package/ios/Plugin/LiveUpdatePlugin.swift +44 -38
  35. package/ios/Plugin/LiveUpdatePreferences.swift +9 -5
  36. package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +1 -0
  37. package/package.json +17 -18
  38. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetBundleOptions.java +0 -18
  39. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBundleResult.java +0 -24
  40. package/ios/Plugin/Classes/Options/SetBundleOptions.swift +0 -14
  41. package/ios/Plugin/Classes/Results/GetBundleResult.swift +0 -16
  42. package/ios/Plugin/LiveUpdatePlugin.h +0 -10
  43. package/ios/Plugin/LiveUpdatePlugin.m +0 -27
@@ -13,17 +13,13 @@ public class LiveUpdateConfig {
13
13
  @Nullable
14
14
  private String defaultChannel = null;
15
15
 
16
- private boolean enabled = true;
17
16
  private int httpTimeout = 60000;
18
17
 
19
- @Nullable
20
- private String location = null;
21
-
22
18
  @Nullable
23
19
  private String publicKey = null;
24
20
 
25
- private int readyTimeout = 10000;
26
- private boolean resetOnUpdate = true;
21
+ private int readyTimeout = 0;
22
+ private String serverDomain = "api.cloud.capawesome.io";
27
23
 
28
24
  @Nullable
29
25
  public String getAppId() {
@@ -39,19 +35,10 @@ public class LiveUpdateConfig {
39
35
  return defaultChannel;
40
36
  }
41
37
 
42
- public boolean getEnabled() {
43
- return enabled;
44
- }
45
-
46
38
  public int getHttpTimeout() {
47
39
  return httpTimeout;
48
40
  }
49
41
 
50
- @Nullable
51
- public String getLocation() {
52
- return location;
53
- }
54
-
55
42
  @Nullable
56
43
  public String getPublicKey() {
57
44
  return publicKey;
@@ -61,8 +48,8 @@ public class LiveUpdateConfig {
61
48
  return readyTimeout;
62
49
  }
63
50
 
64
- public boolean getResetOnUpdate() {
65
- return resetOnUpdate;
51
+ public String getServerDomain() {
52
+ return serverDomain;
66
53
  }
67
54
 
68
55
  public void setAppId(@Nullable String appId) {
@@ -77,18 +64,10 @@ public class LiveUpdateConfig {
77
64
  this.defaultChannel = defaultChannel;
78
65
  }
79
66
 
80
- public void setEnabled(boolean enabled) {
81
- this.enabled = enabled;
82
- }
83
-
84
67
  public void setHttpTimeout(int httpTimeout) {
85
68
  this.httpTimeout = httpTimeout;
86
69
  }
87
70
 
88
- public void setLocation(@Nullable String location) {
89
- this.location = location;
90
- }
91
-
92
71
  public void setPublicKey(@Nullable String publicKey) {
93
72
  this.publicKey = publicKey;
94
73
  }
@@ -97,7 +76,7 @@ public class LiveUpdateConfig {
97
76
  this.readyTimeout = readyTimeout;
98
77
  }
99
78
 
100
- public void setResetOnUpdate(boolean resetOnUpdate) {
101
- this.resetOnUpdate = resetOnUpdate;
79
+ public void setServerDomain(String serverDomain) {
80
+ this.serverDomain = serverDomain;
102
81
  }
103
82
  }
@@ -2,6 +2,8 @@ package io.capawesome.capacitorjs.plugins.liveupdate;
2
2
 
3
3
  import androidx.annotation.NonNull;
4
4
  import androidx.annotation.Nullable;
5
+ import com.getcapacitor.Logger;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.DownloadProgressCallback;
5
7
  import java.io.File;
6
8
  import java.io.IOException;
7
9
  import java.util.concurrent.TimeUnit;
@@ -52,7 +54,8 @@ public class LiveUpdateHttpClient {
52
54
  return okHttpClient.newCall(request).execute();
53
55
  }
54
56
 
55
- public static void writeResponseBodyToFile(ResponseBody body, File file) throws IOException {
57
+ public static void writeResponseBodyToFile(ResponseBody body, File file, @Nullable DownloadProgressCallback callback)
58
+ throws IOException {
56
59
  long contentLength = body.contentLength();
57
60
  BufferedSource source = body.source();
58
61
  BufferedSink sink = Okio.buffer(Okio.sink(file));
@@ -62,7 +65,9 @@ public class LiveUpdateHttpClient {
62
65
  for (long bytesRead; (bytesRead = source.read(sinkBuffer, bufferSize)) != -1;) {
63
66
  sink.emit();
64
67
  totalBytesRead += bytesRead;
65
- int progress = (int) ((totalBytesRead * 100) / contentLength);
68
+ if (callback != null) {
69
+ callback.onProgress(totalBytesRead, contentLength);
70
+ }
66
71
  }
67
72
  sink.flush();
68
73
  sink.close();
@@ -1,15 +1,17 @@
1
1
  package io.capawesome.capacitorjs.plugins.liveupdate;
2
2
 
3
+ import androidx.annotation.NonNull;
3
4
  import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSObject;
4
6
  import com.getcapacitor.Logger;
5
7
  import com.getcapacitor.Plugin;
6
8
  import com.getcapacitor.PluginCall;
7
9
  import com.getcapacitor.PluginMethod;
8
10
  import com.getcapacitor.annotation.CapacitorPlugin;
11
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.events.DownloadBundleProgressEvent;
9
12
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DeleteBundleOptions;
10
13
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DownloadBundleOptions;
11
14
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.FetchLatestBundleOptions;
12
- import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetBundleOptions;
13
15
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetChannelOptions;
14
16
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetCustomIdOptions;
15
17
  import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetNextBundleOptions;
@@ -24,7 +26,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
24
26
  public class LiveUpdatePlugin extends Plugin {
25
27
 
26
28
  public static final String TAG = "LiveUpdate";
27
- public static final String VERSION = "6.7.1";
29
+ public static final String VERSION = "7.0.0";
28
30
  public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
29
31
  public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
30
32
  public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
@@ -42,6 +44,7 @@ public class LiveUpdatePlugin extends Plugin {
42
44
  public static final String ERROR_SIGNATURE_MISSING = "Bundle does not contain a signature.";
43
45
  public static final String ERROR_SYNC_IN_PROGRESS = "Sync is already in progress.";
44
46
  public static final String ERROR_UNKNOWN_ERROR = "An unknown error has occurred.";
47
+ public static final String EVENT_DOWNLOAD_BUNDLE_PROGRESS = "downloadBundleProgress";
45
48
 
46
49
  private boolean syncInProgress = false;
47
50
 
@@ -73,7 +76,7 @@ public class LiveUpdatePlugin extends Plugin {
73
76
  EmptyCallback callback = new EmptyCallback() {
74
77
  @Override
75
78
  public void success() {
76
- call.resolve();
79
+ resolveCall(call);
77
80
  }
78
81
 
79
82
  @Override
@@ -97,18 +100,17 @@ public class LiveUpdatePlugin extends Plugin {
97
100
  call.reject(ERROR_BUNDLE_ID_MISSING);
98
101
  return;
99
102
  }
100
- String checksum = call.getString("checksum");
101
103
  String url = call.getString("url");
102
104
  if (url == null) {
103
105
  call.reject(ERROR_URL_MISSING);
104
106
  return;
105
107
  }
106
108
 
107
- DownloadBundleOptions options = new DownloadBundleOptions(artifactType, bundleId, checksum, url);
109
+ DownloadBundleOptions options = new DownloadBundleOptions(artifactType, bundleId, url);
108
110
  EmptyCallback callback = new EmptyCallback() {
109
111
  @Override
110
112
  public void success() {
111
- call.resolve();
113
+ resolveCall(call);
112
114
  }
113
115
 
114
116
  @Override
@@ -130,7 +132,7 @@ public class LiveUpdatePlugin extends Plugin {
130
132
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
131
133
  @Override
132
134
  public void success(Result result) {
133
- call.resolve(result.toJSObject());
135
+ resolveCall(call, result.toJSObject());
134
136
  }
135
137
 
136
138
  @Override
@@ -145,34 +147,13 @@ public class LiveUpdatePlugin extends Plugin {
145
147
  }
146
148
  }
147
149
 
148
- @PluginMethod
149
- public void getBundle(PluginCall call) {
150
- try {
151
- NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
152
- @Override
153
- public void success(Result result) {
154
- call.resolve(result.toJSObject());
155
- }
156
-
157
- @Override
158
- public void error(Exception exception) {
159
- rejectCall(call, exception);
160
- }
161
- };
162
-
163
- implementation.getBundle(callback);
164
- } catch (Exception exception) {
165
- rejectCall(call, exception);
166
- }
167
- }
168
-
169
150
  @PluginMethod
170
151
  public void getBundles(PluginCall call) {
171
152
  try {
172
153
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
173
154
  @Override
174
155
  public void success(Result result) {
175
- call.resolve(result.toJSObject());
156
+ resolveCall(call, result.toJSObject());
176
157
  }
177
158
 
178
159
  @Override
@@ -193,7 +174,7 @@ public class LiveUpdatePlugin extends Plugin {
193
174
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
194
175
  @Override
195
176
  public void success(Result result) {
196
- call.resolve(result.toJSObject());
177
+ resolveCall(call, result.toJSObject());
197
178
  }
198
179
 
199
180
  @Override
@@ -214,7 +195,7 @@ public class LiveUpdatePlugin extends Plugin {
214
195
  NonEmptyCallback<GetCurrentBundleResult> callback = new NonEmptyCallback<>() {
215
196
  @Override
216
197
  public void success(GetCurrentBundleResult result) {
217
- call.resolve(result.toJSObject());
198
+ resolveCall(call, result.toJSObject());
218
199
  }
219
200
 
220
201
  @Override
@@ -236,7 +217,7 @@ public class LiveUpdatePlugin extends Plugin {
236
217
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
237
218
  @Override
238
219
  public void success(Result result) {
239
- call.resolve(result.toJSObject());
220
+ resolveCall(call, result.toJSObject());
240
221
  }
241
222
 
242
223
  @Override
@@ -257,7 +238,7 @@ public class LiveUpdatePlugin extends Plugin {
257
238
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
258
239
  @Override
259
240
  public void success(Result result) {
260
- call.resolve(result.toJSObject());
241
+ resolveCall(call, result.toJSObject());
261
242
  }
262
243
 
263
244
  @Override
@@ -278,7 +259,7 @@ public class LiveUpdatePlugin extends Plugin {
278
259
  NonEmptyCallback<GetNextBundleResult> callback = new NonEmptyCallback<>() {
279
260
  @Override
280
261
  public void success(GetNextBundleResult result) {
281
- call.resolve(result.toJSObject());
262
+ resolveCall(call, result.toJSObject());
282
263
  }
283
264
 
284
265
  @Override
@@ -300,7 +281,7 @@ public class LiveUpdatePlugin extends Plugin {
300
281
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
301
282
  @Override
302
283
  public void success(Result result) {
303
- call.resolve(result.toJSObject());
284
+ resolveCall(call, result.toJSObject());
304
285
  }
305
286
 
306
287
  @Override
@@ -321,7 +302,7 @@ public class LiveUpdatePlugin extends Plugin {
321
302
  NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
322
303
  @Override
323
304
  public void success(Result result) {
324
- call.resolve(result.toJSObject());
305
+ resolveCall(call, result.toJSObject());
325
306
  }
326
307
 
327
308
  @Override
@@ -339,8 +320,19 @@ public class LiveUpdatePlugin extends Plugin {
339
320
  @PluginMethod
340
321
  public void ready(PluginCall call) {
341
322
  try {
342
- implementation.ready();
343
- call.resolve();
323
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
324
+ @Override
325
+ public void success(Result result) {
326
+ resolveCall(call, result.toJSObject());
327
+ }
328
+
329
+ @Override
330
+ public void error(Exception exception) {
331
+ rejectCall(call, exception);
332
+ }
333
+ };
334
+
335
+ implementation.ready(callback);
344
336
  } catch (Exception exception) {
345
337
  rejectCall(call, exception);
346
338
  }
@@ -350,7 +342,7 @@ public class LiveUpdatePlugin extends Plugin {
350
342
  public void reload(PluginCall call) {
351
343
  try {
352
344
  implementation.reload();
353
- call.resolve();
345
+ resolveCall(call);
354
346
  } catch (Exception exception) {
355
347
  rejectCall(call, exception);
356
348
  }
@@ -360,35 +352,7 @@ public class LiveUpdatePlugin extends Plugin {
360
352
  public void reset(PluginCall call) {
361
353
  try {
362
354
  implementation.reset();
363
- call.resolve();
364
- } catch (Exception exception) {
365
- rejectCall(call, exception);
366
- }
367
- }
368
-
369
- @PluginMethod
370
- public void setBundle(PluginCall call) {
371
- try {
372
- String bundleId = call.getString("bundleId");
373
- if (bundleId == null) {
374
- call.reject(ERROR_BUNDLE_ID_MISSING);
375
- return;
376
- }
377
-
378
- SetBundleOptions options = new SetBundleOptions(bundleId);
379
- EmptyCallback callback = new EmptyCallback() {
380
- @Override
381
- public void success() {
382
- call.resolve();
383
- }
384
-
385
- @Override
386
- public void error(Exception exception) {
387
- rejectCall(call, exception);
388
- }
389
- };
390
-
391
- implementation.setBundle(options, callback);
355
+ resolveCall(call);
392
356
  } catch (Exception exception) {
393
357
  rejectCall(call, exception);
394
358
  }
@@ -403,7 +367,7 @@ public class LiveUpdatePlugin extends Plugin {
403
367
  EmptyCallback callback = new EmptyCallback() {
404
368
  @Override
405
369
  public void success() {
406
- call.resolve();
370
+ resolveCall(call);
407
371
  }
408
372
 
409
373
  @Override
@@ -431,7 +395,7 @@ public class LiveUpdatePlugin extends Plugin {
431
395
  EmptyCallback callback = new EmptyCallback() {
432
396
  @Override
433
397
  public void success() {
434
- call.resolve();
398
+ resolveCall(call);
435
399
  }
436
400
 
437
401
  @Override
@@ -453,7 +417,7 @@ public class LiveUpdatePlugin extends Plugin {
453
417
  EmptyCallback callback = new EmptyCallback() {
454
418
  @Override
455
419
  public void success() {
456
- call.resolve();
420
+ resolveCall(call);
457
421
  }
458
422
 
459
423
  @Override
@@ -488,7 +452,7 @@ public class LiveUpdatePlugin extends Plugin {
488
452
  @Override
489
453
  public void success(Result result) {
490
454
  syncInProgress = false;
491
- call.resolve(result.toJSObject());
455
+ resolveCall(call, result.toJSObject());
492
456
  }
493
457
 
494
458
  @Override
@@ -505,6 +469,10 @@ public class LiveUpdatePlugin extends Plugin {
505
469
  }
506
470
  }
507
471
 
472
+ public void notifyDownloadBundleProgressListeners(@NonNull DownloadBundleProgressEvent event) {
473
+ notifyListeners(EVENT_DOWNLOAD_BUNDLE_PROGRESS, event.toJSObject(), false);
474
+ }
475
+
508
476
  private LiveUpdateConfig getLiveUpdateConfig() {
509
477
  LiveUpdateConfig config = new LiveUpdateConfig();
510
478
 
@@ -514,22 +482,26 @@ public class LiveUpdatePlugin extends Plugin {
514
482
  config.setAutoDeleteBundles(autoDeleteBundles);
515
483
  String defaultChannel = getConfig().getString("defaultChannel", config.getDefaultChannel());
516
484
  config.setDefaultChannel(defaultChannel);
517
- boolean enabled = getConfig().getBoolean("enabled", config.getEnabled());
518
- config.setEnabled(enabled);
519
485
  int httpTimeout = getConfig().getInt("httpTimeout", config.getHttpTimeout());
520
486
  config.setHttpTimeout(httpTimeout);
521
- String location = getConfig().getString("location", config.getLocation());
522
- config.setLocation(location);
523
487
  String publicKey = getConfig().getString("publicKey", config.getPublicKey());
524
488
  config.setPublicKey(publicKey);
525
489
  int readyTimeout = getConfig().getInt("readyTimeout", config.getReadyTimeout());
526
490
  config.setReadyTimeout(readyTimeout);
527
- boolean resetOnUpdate = getConfig().getBoolean("resetOnUpdate", config.getResetOnUpdate());
528
- config.setResetOnUpdate(resetOnUpdate);
491
+ String serverDomain = getConfig().getString("serverDomain", config.getServerDomain());
492
+ config.setServerDomain(serverDomain);
529
493
 
530
494
  return config;
531
495
  }
532
496
 
497
+ private void resolveCall(@NonNull PluginCall call) {
498
+ call.resolve();
499
+ }
500
+
501
+ private void resolveCall(@NonNull PluginCall call, @NonNull JSObject result) {
502
+ call.resolve(result);
503
+ }
504
+
533
505
  private void rejectCall(PluginCall call, Exception exception) {
534
506
  String message = exception.getMessage();
535
507
  if (exception instanceof java.net.SocketTimeoutException) {
@@ -18,7 +18,7 @@ public class LiveUpdatePreferences {
18
18
  private final String channelKey = "channel"; // DO NOT CHANGE
19
19
  private final String deviceIdKey = "deviceId"; // DO NOT CHANGE
20
20
  private final String customIdKey = "customId"; // DO NOT CHANGE
21
- private final String lastVersionCodeKey = "lastVersionCode"; // DO NOT CHANGE
21
+ private final String previousBundleIdKey = "previousBundleId"; // DO NOT CHANGE
22
22
 
23
23
  public LiveUpdatePreferences(@NonNull Context context) {
24
24
  this.context = context;
@@ -48,8 +48,11 @@ public class LiveUpdatePreferences {
48
48
  }
49
49
  }
50
50
 
51
- public int getLastVersionCode() {
52
- return context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).getInt(lastVersionCodeKey, 0);
51
+ @Nullable
52
+ public String getPreviousBundleId() {
53
+ return context
54
+ .getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE)
55
+ .getString(previousBundleIdKey, null);
53
56
  }
54
57
 
55
58
  public void setChannel(@Nullable String channel) {
@@ -79,8 +82,12 @@ public class LiveUpdatePreferences {
79
82
  settingsEditor.apply();
80
83
  }
81
84
 
82
- public void setLastVersionCode(int lastVersionCode) {
83
- settingsEditor.putInt(lastVersionCodeKey, lastVersionCode);
85
+ public void setPreviousBundleId(@Nullable String bundleId) {
86
+ if (bundleId == null) {
87
+ settingsEditor.remove(previousBundleIdKey);
88
+ } else {
89
+ settingsEditor.putString(previousBundleIdKey, bundleId);
90
+ }
84
91
  settingsEditor.apply();
85
92
  }
86
93
  }
@@ -16,6 +16,9 @@ public class GetLatestBundleResponse {
16
16
  @NonNull
17
17
  private String bundleId;
18
18
 
19
+ @Nullable
20
+ private JSONObject customProperties;
21
+
19
22
  @NonNull
20
23
  private String url;
21
24
 
@@ -27,6 +30,7 @@ public class GetLatestBundleResponse {
27
30
  this.artifactType = ArtifactType.ZIP;
28
31
  }
29
32
  this.bundleId = responseJson.optString("bundleId");
33
+ this.customProperties = responseJson.optJSONObject("customProperties");
30
34
  this.url = responseJson.optString("url");
31
35
  }
32
36
 
@@ -40,6 +44,11 @@ public class GetLatestBundleResponse {
40
44
  return bundleId;
41
45
  }
42
46
 
47
+ @Nullable
48
+ public JSONObject getCustomProperties() {
49
+ return customProperties;
50
+ }
51
+
43
52
  @NonNull
44
53
  public String getUrl() {
45
54
  return url;
@@ -0,0 +1,32 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.events;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
6
+
7
+ public class DownloadBundleProgressEvent implements Result {
8
+
9
+ @NonNull
10
+ private final String bundleId;
11
+
12
+ private final long downloadedBytes;
13
+ private final long totalBytes;
14
+ private final double progress;
15
+
16
+ public DownloadBundleProgressEvent(@NonNull String bundleId, long downloadedBytes, long totalBytes) {
17
+ this.bundleId = bundleId;
18
+ this.downloadedBytes = downloadedBytes;
19
+ this.totalBytes = totalBytes;
20
+ this.progress = (double) downloadedBytes / (double) totalBytes;
21
+ }
22
+
23
+ @NonNull
24
+ public JSObject toJSObject() {
25
+ JSObject result = new JSObject();
26
+ result.put("bundleId", bundleId);
27
+ result.put("downloadedBytes", downloadedBytes);
28
+ result.put("progress", progress);
29
+ result.put("totalBytes", totalBytes);
30
+ return result;
31
+ }
32
+ }
@@ -12,20 +12,16 @@ public class DownloadBundleOptions {
12
12
  @NonNull
13
13
  private String bundleId;
14
14
 
15
- @Nullable
16
- private String checksum;
17
-
18
15
  @NonNull
19
16
  private String url;
20
17
 
21
- public DownloadBundleOptions(@NonNull String artifactType, @NonNull String bundleId, @Nullable String checksum, @NonNull String url) {
18
+ public DownloadBundleOptions(@NonNull String artifactType, @NonNull String bundleId, @NonNull String url) {
22
19
  if (artifactType.equals("manifest")) {
23
20
  this.artifactType = ArtifactType.MANIFEST;
24
21
  } else {
25
22
  this.artifactType = ArtifactType.ZIP;
26
23
  }
27
24
  this.bundleId = bundleId;
28
- this.checksum = checksum;
29
25
  this.url = url;
30
26
  }
31
27
 
@@ -39,11 +35,6 @@ public class DownloadBundleOptions {
39
35
  return bundleId;
40
36
  }
41
37
 
42
- @Nullable
43
- public String getChecksum() {
44
- return checksum;
45
- }
46
-
47
38
  @NonNull
48
39
  public String getUrl() {
49
40
  return url;
@@ -15,12 +15,21 @@ public class FetchLatestBundleResult implements Result {
15
15
  @Nullable
16
16
  private final String bundleId;
17
17
 
18
+ @Nullable
19
+ private final JSONObject customProperties;
20
+
18
21
  @Nullable
19
22
  private final String downloadUrl;
20
23
 
21
- public FetchLatestBundleResult(@Nullable ArtifactType artifactType, @Nullable String bundleId, @Nullable String downloadUrl) {
24
+ public FetchLatestBundleResult(
25
+ @Nullable ArtifactType artifactType,
26
+ @Nullable String bundleId,
27
+ @Nullable JSONObject customProperties,
28
+ @Nullable String downloadUrl
29
+ ) {
22
30
  this.artifactType = artifactType;
23
31
  this.bundleId = bundleId;
32
+ this.customProperties = customProperties;
24
33
  this.downloadUrl = downloadUrl;
25
34
  }
26
35
 
@@ -33,6 +42,9 @@ public class FetchLatestBundleResult implements Result {
33
42
  result.put("artifactType", "zip");
34
43
  }
35
44
  result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
45
+ if (customProperties != null) {
46
+ result.put("customProperties", customProperties);
47
+ }
36
48
  if (downloadUrl != null) {
37
49
  result.put("downloadUrl", downloadUrl);
38
50
  }
@@ -0,0 +1,32 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.liveupdate.LiveUpdate;
6
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
7
+ import org.json.JSONObject;
8
+
9
+ public class ReadyResult implements Result {
10
+
11
+ @Nullable
12
+ private String currentBundleId;
13
+
14
+ @Nullable
15
+ private String previousBundleId;
16
+
17
+ private boolean rollback;
18
+
19
+ public ReadyResult(@Nullable String currentBundleId, @Nullable String previousBundleId, boolean rollback) {
20
+ this.currentBundleId = currentBundleId;
21
+ this.previousBundleId = previousBundleId;
22
+ this.rollback = rollback;
23
+ }
24
+
25
+ public JSObject toJSObject() {
26
+ JSObject result = new JSObject();
27
+ result.put("currentBundleId", currentBundleId == null ? JSONObject.NULL : currentBundleId);
28
+ result.put("previousBundleId", previousBundleId == null ? JSONObject.NULL : previousBundleId);
29
+ result.put("rollback", rollback);
30
+ return result;
31
+ }
32
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.interfaces;
2
+
3
+ public interface DownloadProgressCallback {
4
+ void onProgress(long downloadedBytes, long totalBytes);
5
+ }