@capawesome/capacitor-live-update 5.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 (66) hide show
  1. package/CapawesomeCapacitorLiveUpdate.podspec +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +509 -0
  4. package/android/build.gradle +62 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +613 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +55 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +437 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +86 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +23 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DeleteBundleOptions.java +18 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +27 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetBundleOptions.java +18 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetChannelOptions.java +18 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetCustomIdOptions.java +18 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBundleResult.java +24 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBundlesResult.java +27 -0
  18. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetChannelResult.java +21 -0
  19. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetCustomIdResult.java +22 -0
  20. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetDeviceIdResult.java +22 -0
  21. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetVersionCodeResult.java +21 -0
  22. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetVersionNameResult.java +21 -0
  23. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/SyncResult.java +22 -0
  24. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/Callback.java +5 -0
  25. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/EmptyCallback.java +5 -0
  26. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/NonEmptyCallback.java +7 -0
  27. package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/Result.java +7 -0
  28. package/android/src/main/res/.gitkeep +0 -0
  29. package/dist/docs.json +785 -0
  30. package/dist/esm/definitions.d.ts +356 -0
  31. package/dist/esm/definitions.js +3 -0
  32. package/dist/esm/definitions.js.map +1 -0
  33. package/dist/esm/index.d.ts +4 -0
  34. package/dist/esm/index.js +7 -0
  35. package/dist/esm/index.js.map +1 -0
  36. package/dist/esm/web.d.ts +21 -0
  37. package/dist/esm/web.js +55 -0
  38. package/dist/esm/web.js.map +1 -0
  39. package/dist/plugin.cjs.js +71 -0
  40. package/dist/plugin.cjs.js.map +1 -0
  41. package/dist/plugin.js +74 -0
  42. package/dist/plugin.js.map +1 -0
  43. package/ios/Plugin/Classes/CustomError.swift +38 -0
  44. package/ios/Plugin/Classes/Options/DeleteBundleOptions.swift +14 -0
  45. package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +20 -0
  46. package/ios/Plugin/Classes/Options/SetBundleOptions.swift +14 -0
  47. package/ios/Plugin/Classes/Options/SetChannelOptions.swift +14 -0
  48. package/ios/Plugin/Classes/Options/SetCustomIdOptions.swift +14 -0
  49. package/ios/Plugin/Classes/Results/GetBundleResult.swift +16 -0
  50. package/ios/Plugin/Classes/Results/GetBundlesResult.swift +16 -0
  51. package/ios/Plugin/Classes/Results/GetChannelResult.swift +16 -0
  52. package/ios/Plugin/Classes/Results/GetCustomIdResult.swift +16 -0
  53. package/ios/Plugin/Classes/Results/GetDeviceIdResult.swift +16 -0
  54. package/ios/Plugin/Classes/Results/GetVersionCodeResult.swift +16 -0
  55. package/ios/Plugin/Classes/Results/GetVersionNameResult.swift +16 -0
  56. package/ios/Plugin/Classes/Results/SyncResult.swift +16 -0
  57. package/ios/Plugin/Info.plist +24 -0
  58. package/ios/Plugin/LiveUpdate.swift +512 -0
  59. package/ios/Plugin/LiveUpdateConfig.swift +7 -0
  60. package/ios/Plugin/LiveUpdatePlugin.h +10 -0
  61. package/ios/Plugin/LiveUpdatePlugin.m +23 -0
  62. package/ios/Plugin/LiveUpdatePlugin.swift +247 -0
  63. package/ios/Plugin/LiveUpdatePreferences.swift +60 -0
  64. package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +4 -0
  65. package/ios/Plugin/Protocols/Result.swift +6 -0
  66. package/package.json +92 -0
@@ -0,0 +1,437 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.getcapacitor.Logger;
5
+ import com.getcapacitor.Plugin;
6
+ import com.getcapacitor.PluginCall;
7
+ import com.getcapacitor.PluginMethod;
8
+ import com.getcapacitor.annotation.CapacitorPlugin;
9
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DeleteBundleOptions;
10
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.DownloadBundleOptions;
11
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetBundleOptions;
12
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetChannelOptions;
13
+ import io.capawesome.capacitorjs.plugins.liveupdate.classes.options.SetCustomIdOptions;
14
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.EmptyCallback;
15
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.NonEmptyCallback;
16
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
17
+
18
+ @CapacitorPlugin(name = "LiveUpdate")
19
+ public class LiveUpdatePlugin extends Plugin {
20
+
21
+ public static final String TAG = "LiveUpdate";
22
+ public static final String VERSION = "5.0.0";
23
+ public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
24
+ public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
25
+ public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
26
+ public static final String ERROR_BUNDLE_ID_MISSING = "bundleId must be provided.";
27
+ public static final String ERROR_BUNDLE_INDEX_HTML_MISSING = "The bundle does not contain an index.html file.";
28
+ public static final String ERROR_BUNDLE_NOT_FOUND = "bundle not found.";
29
+ public static final String ERROR_CUSTOM_ID_MISSING = "customId must be provided.";
30
+ public static final String ERROR_DOWNLOAD_FAILED = "Bundle could not be downloaded.";
31
+ public static final String ERROR_URL_MISSING = "url must be provided.";
32
+
33
+ @Nullable
34
+ private LiveUpdateConfig config;
35
+
36
+ @Nullable
37
+ private LiveUpdate implementation;
38
+
39
+ public void load() {
40
+ try {
41
+ config = getLiveUpdateConfig();
42
+ implementation = new LiveUpdate(config, this);
43
+ } catch (Exception exception) {
44
+ Logger.error(TAG, exception.getMessage(), exception);
45
+ }
46
+ }
47
+
48
+ @PluginMethod
49
+ public void deleteBundle(PluginCall call) {
50
+ try {
51
+ String bundleId = call.getString("bundleId");
52
+ if (bundleId == null) {
53
+ call.reject(ERROR_BUNDLE_ID_MISSING);
54
+ return;
55
+ }
56
+
57
+ DeleteBundleOptions options = new DeleteBundleOptions(bundleId);
58
+ EmptyCallback callback = new EmptyCallback() {
59
+ @Override
60
+ public void success() {
61
+ call.resolve();
62
+ }
63
+
64
+ @Override
65
+ public void error(Exception exception) {
66
+ Logger.error(TAG, exception.getMessage(), exception);
67
+ call.reject(exception.getMessage());
68
+ }
69
+ };
70
+
71
+ implementation.deleteBundle(options, callback);
72
+ } catch (Exception exception) {
73
+ Logger.error(TAG, exception.getMessage(), exception);
74
+ call.reject(exception.getMessage());
75
+ }
76
+ }
77
+
78
+ @PluginMethod
79
+ public void downloadBundle(PluginCall call) {
80
+ try {
81
+ String url = call.getString("url");
82
+ if (url == null) {
83
+ call.reject(ERROR_URL_MISSING);
84
+ return;
85
+ }
86
+ String bundleId = call.getString("bundleId");
87
+ if (bundleId == null) {
88
+ call.reject(ERROR_BUNDLE_ID_MISSING);
89
+ return;
90
+ }
91
+
92
+ DownloadBundleOptions options = new DownloadBundleOptions(bundleId, url);
93
+ EmptyCallback callback = new EmptyCallback() {
94
+ @Override
95
+ public void success() {
96
+ call.resolve();
97
+ }
98
+
99
+ @Override
100
+ public void error(Exception exception) {
101
+ Logger.error(TAG, exception.getMessage(), exception);
102
+ call.reject(exception.getMessage());
103
+ }
104
+ };
105
+
106
+ implementation.downloadBundle(options, callback);
107
+ } catch (Exception exception) {
108
+ Logger.error(TAG, exception.getMessage(), exception);
109
+ call.reject(exception.getMessage());
110
+ }
111
+ }
112
+
113
+ @PluginMethod
114
+ public void getBundle(PluginCall call) {
115
+ try {
116
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
117
+ @Override
118
+ public void success(Result result) {
119
+ call.resolve(result.toJSObject());
120
+ }
121
+
122
+ @Override
123
+ public void error(Exception exception) {
124
+ Logger.error(TAG, exception.getMessage(), exception);
125
+ call.reject(exception.getMessage());
126
+ }
127
+ };
128
+
129
+ implementation.getBundle(callback);
130
+ } catch (Exception exception) {
131
+ Logger.error(TAG, exception.getMessage(), exception);
132
+ call.reject(exception.getMessage());
133
+ }
134
+ }
135
+
136
+ @PluginMethod
137
+ public void getBundles(PluginCall call) {
138
+ try {
139
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
140
+ @Override
141
+ public void success(Result result) {
142
+ call.resolve(result.toJSObject());
143
+ }
144
+
145
+ @Override
146
+ public void error(Exception exception) {
147
+ Logger.error(TAG, exception.getMessage(), exception);
148
+ call.reject(exception.getMessage());
149
+ }
150
+ };
151
+
152
+ implementation.getBundles(callback);
153
+ } catch (Exception exception) {
154
+ Logger.error(TAG, exception.getMessage(), exception);
155
+ call.reject(exception.getMessage());
156
+ }
157
+ }
158
+
159
+ @PluginMethod
160
+ public void getChannel(PluginCall call) {
161
+ try {
162
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
163
+ @Override
164
+ public void success(Result result) {
165
+ call.resolve(result.toJSObject());
166
+ }
167
+
168
+ @Override
169
+ public void error(Exception exception) {
170
+ Logger.error(TAG, exception.getMessage(), exception);
171
+ call.reject(exception.getMessage());
172
+ }
173
+ };
174
+
175
+ implementation.getChannel(callback);
176
+ } catch (Exception exception) {
177
+ Logger.error(TAG, exception.getMessage(), exception);
178
+ call.reject(exception.getMessage());
179
+ }
180
+ }
181
+
182
+ @PluginMethod
183
+ public void getCustomId(PluginCall call) {
184
+ try {
185
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
186
+ @Override
187
+ public void success(Result result) {
188
+ call.resolve(result.toJSObject());
189
+ }
190
+
191
+ @Override
192
+ public void error(Exception exception) {
193
+ Logger.error(TAG, exception.getMessage(), exception);
194
+ call.reject(exception.getMessage());
195
+ }
196
+ };
197
+
198
+ implementation.getCustomId(callback);
199
+ } catch (Exception exception) {
200
+ Logger.error(TAG, exception.getMessage(), exception);
201
+ call.reject(exception.getMessage());
202
+ }
203
+ }
204
+
205
+ @PluginMethod
206
+ public void getDeviceId(PluginCall call) {
207
+ try {
208
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
209
+ @Override
210
+ public void success(Result result) {
211
+ call.resolve(result.toJSObject());
212
+ }
213
+
214
+ @Override
215
+ public void error(Exception exception) {
216
+ Logger.error(TAG, exception.getMessage(), exception);
217
+ call.reject(exception.getMessage());
218
+ }
219
+ };
220
+
221
+ implementation.getDeviceId(callback);
222
+ } catch (Exception exception) {
223
+ Logger.error(TAG, exception.getMessage(), exception);
224
+ call.reject(exception.getMessage());
225
+ }
226
+ }
227
+
228
+ @PluginMethod
229
+ public void getVersionCode(PluginCall call) {
230
+ try {
231
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
232
+ @Override
233
+ public void success(Result result) {
234
+ call.resolve(result.toJSObject());
235
+ }
236
+
237
+ @Override
238
+ public void error(Exception exception) {
239
+ Logger.error(TAG, exception.getMessage(), exception);
240
+ call.reject(exception.getMessage());
241
+ }
242
+ };
243
+
244
+ implementation.getVersionCode(callback);
245
+ } catch (Exception exception) {
246
+ Logger.error(TAG, exception.getMessage(), exception);
247
+ call.reject(exception.getMessage());
248
+ }
249
+ }
250
+
251
+ @PluginMethod
252
+ public void getVersionName(PluginCall call) {
253
+ try {
254
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
255
+ @Override
256
+ public void success(Result result) {
257
+ call.resolve(result.toJSObject());
258
+ }
259
+
260
+ @Override
261
+ public void error(Exception exception) {
262
+ Logger.error(TAG, exception.getMessage(), exception);
263
+ call.reject(exception.getMessage());
264
+ }
265
+ };
266
+
267
+ implementation.getVersionName(callback);
268
+ } catch (Exception exception) {
269
+ Logger.error(TAG, exception.getMessage(), exception);
270
+ call.reject(exception.getMessage());
271
+ }
272
+ }
273
+
274
+ @PluginMethod
275
+ public void ready(PluginCall call) {
276
+ try {
277
+ implementation.ready();
278
+ call.resolve();
279
+ } catch (Exception exception) {
280
+ Logger.error(TAG, exception.getMessage(), exception);
281
+ call.reject(exception.getMessage());
282
+ }
283
+ }
284
+
285
+ @PluginMethod
286
+ public void reload(PluginCall call) {
287
+ try {
288
+ implementation.reload();
289
+ call.resolve();
290
+ } catch (Exception exception) {
291
+ Logger.error(TAG, exception.getMessage(), exception);
292
+ call.reject(exception.getMessage());
293
+ }
294
+ }
295
+
296
+ @PluginMethod
297
+ public void reset(PluginCall call) {
298
+ try {
299
+ implementation.reset();
300
+ call.resolve();
301
+ } catch (Exception exception) {
302
+ Logger.error(TAG, exception.getMessage(), exception);
303
+ call.reject(exception.getMessage());
304
+ }
305
+ }
306
+
307
+ @PluginMethod
308
+ public void setBundle(PluginCall call) {
309
+ try {
310
+ String bundleId = call.getString("bundleId");
311
+ if (bundleId == null) {
312
+ call.reject(ERROR_BUNDLE_ID_MISSING);
313
+ return;
314
+ }
315
+
316
+ SetBundleOptions options = new SetBundleOptions(bundleId);
317
+ EmptyCallback callback = new EmptyCallback() {
318
+ @Override
319
+ public void success() {
320
+ call.resolve();
321
+ }
322
+
323
+ @Override
324
+ public void error(Exception exception) {
325
+ Logger.error(TAG, exception.getMessage(), exception);
326
+ call.reject(exception.getMessage());
327
+ }
328
+ };
329
+
330
+ implementation.setBundle(options, callback);
331
+ } catch (Exception exception) {
332
+ Logger.error(TAG, exception.getMessage(), exception);
333
+ call.reject(exception.getMessage());
334
+ }
335
+ }
336
+
337
+ @PluginMethod
338
+ public void setChannel(PluginCall call) {
339
+ try {
340
+ String channel = call.getString("channel");
341
+
342
+ SetChannelOptions options = new SetChannelOptions(channel);
343
+ EmptyCallback callback = new EmptyCallback() {
344
+ @Override
345
+ public void success() {
346
+ call.resolve();
347
+ }
348
+
349
+ @Override
350
+ public void error(Exception exception) {
351
+ Logger.error(TAG, exception.getMessage(), exception);
352
+ call.reject(exception.getMessage());
353
+ }
354
+ };
355
+
356
+ implementation.setChannel(options, callback);
357
+ } catch (Exception exception) {
358
+ Logger.error(TAG, exception.getMessage(), exception);
359
+ call.reject(exception.getMessage());
360
+ }
361
+ }
362
+
363
+ @PluginMethod
364
+ public void setCustomId(PluginCall call) {
365
+ try {
366
+ String customId = call.getString("customId");
367
+ if (customId == null) {
368
+ call.reject(ERROR_CUSTOM_ID_MISSING);
369
+ return;
370
+ }
371
+
372
+ SetCustomIdOptions options = new SetCustomIdOptions(customId);
373
+ EmptyCallback callback = new EmptyCallback() {
374
+ @Override
375
+ public void success() {
376
+ call.resolve();
377
+ }
378
+
379
+ @Override
380
+ public void error(Exception exception) {
381
+ Logger.error(TAG, exception.getMessage(), exception);
382
+ call.reject(exception.getMessage());
383
+ }
384
+ };
385
+
386
+ implementation.setCustomId(options, callback);
387
+ } catch (Exception exception) {
388
+ Logger.error(TAG, exception.getMessage(), exception);
389
+ call.reject(exception.getMessage());
390
+ }
391
+ }
392
+
393
+ @PluginMethod
394
+ public void sync(PluginCall call) {
395
+ try {
396
+ String appId = config.getAppId();
397
+ if (appId == null) {
398
+ call.reject(ERROR_APP_ID_MISSING);
399
+ return;
400
+ }
401
+ NonEmptyCallback<Result> callback = new NonEmptyCallback<>() {
402
+ @Override
403
+ public void success(Result result) {
404
+ call.resolve(result.toJSObject());
405
+ }
406
+
407
+ @Override
408
+ public void error(Exception exception) {
409
+ Logger.error(TAG, exception.getMessage(), exception);
410
+ call.reject(exception.getMessage());
411
+ }
412
+ };
413
+
414
+ implementation.sync(callback);
415
+ } catch (Exception exception) {
416
+ Logger.error(TAG, exception.getMessage(), exception);
417
+ call.reject(exception.getMessage());
418
+ }
419
+ }
420
+
421
+ private LiveUpdateConfig getLiveUpdateConfig() {
422
+ LiveUpdateConfig config = new LiveUpdateConfig();
423
+
424
+ String appId = getConfig().getString("appId", config.getAppId());
425
+ config.setAppId(appId);
426
+ boolean autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.getAutoDeleteBundles());
427
+ config.setAutoDeleteBundles(autoDeleteBundles);
428
+ boolean enabled = getConfig().getBoolean("enabled", config.getEnabled());
429
+ config.setEnabled(enabled);
430
+ int readyTimeout = getConfig().getInt("readyTimeout", config.getReadyTimeout());
431
+ config.setReadyTimeout(readyTimeout);
432
+ boolean resetOnUpdate = getConfig().getBoolean("resetOnUpdate", config.getResetOnUpdate());
433
+ config.setResetOnUpdate(resetOnUpdate);
434
+
435
+ return config;
436
+ }
437
+ }
@@ -0,0 +1,86 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate;
2
+
3
+ import android.app.Activity;
4
+ import android.content.Context;
5
+ import android.content.SharedPreferences;
6
+ import androidx.annotation.NonNull;
7
+ import androidx.annotation.Nullable;
8
+ import java.util.UUID;
9
+
10
+ public class LiveUpdatePreferences {
11
+
12
+ @NonNull
13
+ private final Context context;
14
+
15
+ @NonNull
16
+ private final SharedPreferences.Editor settingsEditor;
17
+
18
+ private final String channelKey = "channel"; // DO NOT CHANGE
19
+ private final String deviceIdKey = "deviceId"; // DO NOT CHANGE
20
+ private final String customIdKey = "customId"; // DO NOT CHANGE
21
+ private final String lastVersionCodeKey = "lastVersionCode"; // DO NOT CHANGE
22
+
23
+ public LiveUpdatePreferences(@NonNull Context context) {
24
+ this.context = context;
25
+ this.settingsEditor = context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).edit();
26
+ }
27
+
28
+ @Nullable
29
+ public String getChannel() {
30
+ return context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).getString(channelKey, null);
31
+ }
32
+
33
+ @Nullable
34
+ public String getCustomId() {
35
+ return context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).getString(customIdKey, null);
36
+ }
37
+
38
+ @Nullable
39
+ public String getDeviceIdForApp(@Nullable String appId) {
40
+ if (appId == null) {
41
+ return context
42
+ .getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE)
43
+ .getString(deviceIdKey, null);
44
+ } else {
45
+ return context
46
+ .getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE)
47
+ .getString(deviceIdKey + "_" + appId, null);
48
+ }
49
+ }
50
+
51
+ public int getLastVersionCode() {
52
+ return context.getSharedPreferences(LiveUpdatePlugin.SHARED_PREFERENCES_NAME, Activity.MODE_PRIVATE).getInt(lastVersionCodeKey, 0);
53
+ }
54
+
55
+ public void setChannel(@Nullable String channel) {
56
+ if (channel == null) {
57
+ settingsEditor.remove(channelKey);
58
+ } else {
59
+ settingsEditor.putString(channelKey, channel);
60
+ }
61
+ settingsEditor.apply();
62
+ }
63
+
64
+ public void setCustomId(@Nullable String customId) {
65
+ if (customId == null) {
66
+ settingsEditor.remove(customIdKey);
67
+ } else {
68
+ settingsEditor.putString(customIdKey, customId);
69
+ }
70
+ settingsEditor.apply();
71
+ }
72
+
73
+ public void setDeviceIdForApp(@Nullable String appId, @NonNull String deviceId) {
74
+ if (appId == null) {
75
+ settingsEditor.putString(deviceIdKey, deviceId);
76
+ } else {
77
+ settingsEditor.putString(deviceIdKey + "_" + appId, deviceId);
78
+ }
79
+ settingsEditor.apply();
80
+ }
81
+
82
+ public void setLastVersionCode(int lastVersionCode) {
83
+ settingsEditor.putInt(lastVersionCodeKey, lastVersionCode);
84
+ settingsEditor.apply();
85
+ }
86
+ }
@@ -0,0 +1,23 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.api;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import org.json.JSONObject;
5
+
6
+ public class GetLatestBundleResponse {
7
+
8
+ private String bundleId;
9
+ private String url;
10
+
11
+ public GetLatestBundleResponse(JSONObject responseJson) {
12
+ this.bundleId = responseJson.optString("bundleId");
13
+ this.url = responseJson.optString("url");
14
+ }
15
+
16
+ public String getBundleId() {
17
+ return bundleId;
18
+ }
19
+
20
+ public String getUrl() {
21
+ return url;
22
+ }
23
+ }
@@ -0,0 +1,18 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public class DeleteBundleOptions {
6
+
7
+ @NonNull
8
+ private String bundleId;
9
+
10
+ public DeleteBundleOptions(@NonNull String bundleId) {
11
+ this.bundleId = bundleId;
12
+ }
13
+
14
+ @NonNull
15
+ public String getBundleId() {
16
+ return bundleId;
17
+ }
18
+ }
@@ -0,0 +1,27 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public class DownloadBundleOptions {
6
+
7
+ @NonNull
8
+ private String bundleId;
9
+
10
+ @NonNull
11
+ private String url;
12
+
13
+ public DownloadBundleOptions(@NonNull String bundleId, @NonNull String url) {
14
+ this.bundleId = bundleId;
15
+ this.url = url;
16
+ }
17
+
18
+ @NonNull
19
+ public String getBundleId() {
20
+ return bundleId;
21
+ }
22
+
23
+ @NonNull
24
+ public String getUrl() {
25
+ return url;
26
+ }
27
+ }
@@ -0,0 +1,18 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public class SetBundleOptions {
6
+
7
+ @NonNull
8
+ private String bundleId;
9
+
10
+ public SetBundleOptions(@NonNull String bundleId) {
11
+ this.bundleId = bundleId;
12
+ }
13
+
14
+ @NonNull
15
+ public String getBundleId() {
16
+ return bundleId;
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public class SetChannelOptions {
6
+
7
+ @NonNull
8
+ private String channel;
9
+
10
+ public SetChannelOptions(@NonNull String channel) {
11
+ this.channel = channel;
12
+ }
13
+
14
+ @NonNull
15
+ public String getChannel() {
16
+ return channel;
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.options;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public class SetCustomIdOptions {
6
+
7
+ @NonNull
8
+ private String customId;
9
+
10
+ public SetCustomIdOptions(@NonNull String customId) {
11
+ this.customId = customId;
12
+ }
13
+
14
+ @NonNull
15
+ public String getCustomId() {
16
+ return customId;
17
+ }
18
+ }
@@ -0,0 +1,24 @@
1
+ package io.capawesome.capacitorjs.plugins.liveupdate.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+ import com.getcapacitor.JSArray;
6
+ import com.getcapacitor.JSObject;
7
+ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
8
+ import org.json.JSONObject;
9
+
10
+ public class GetBundleResult implements Result {
11
+
12
+ @Nullable
13
+ private String bundleId;
14
+
15
+ public GetBundleResult(@Nullable String bundleId) {
16
+ this.bundleId = bundleId;
17
+ }
18
+
19
+ public JSObject toJSObject() {
20
+ JSObject result = new JSObject();
21
+ result.put("bundleId", bundleId == null ? JSONObject.NULL : bundleId);
22
+ return result;
23
+ }
24
+ }