@capgo/capacitor-updater 4.0.0-alpha.26 → 4.0.0-alpha.29

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
@@ -162,14 +162,14 @@ Notify Capacitor Updater that the current bundle is working (a rollback will occ
162
162
  ### download(...)
163
163
 
164
164
  ```typescript
165
- download(options: { url: string; version?: string; }) => Promise<BundleInfo>
165
+ download(options: { url: string; version: string; }) => Promise<BundleInfo>
166
166
  ```
167
167
 
168
168
  Download a new version from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files
169
169
 
170
- | Param | Type |
171
- | ------------- | ----------------------------------------------- |
172
- | **`options`** | <code>{ url: string; version?: string; }</code> |
170
+ | Param | Type |
171
+ | ------------- | ---------------------------------------------- |
172
+ | **`options`** | <code>{ url: string; version: string; }</code> |
173
173
 
174
174
  **Returns:** <code>Promise&lt;<a href="#bundleinfo">BundleInfo</a>&gt;</code>
175
175
 
@@ -390,7 +390,7 @@ Listen for Major update event in the App, let you know when major update is bloc
390
390
  addListener(eventName: 'updateFailed', listenerFunc: UpdateFailedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
391
391
  ```
392
392
 
393
- Listen for update event in the App, let you know when update is ready to install at next app start
393
+ Listen for update fail event in the App, let you know when update hs fail to install at next app start
394
394
 
395
395
  | Param | Type |
396
396
  | ------------------ | --------------------------------------------------------------------- |
@@ -46,7 +46,7 @@ public class CapacitorUpdater {
46
46
  private static final String bundleDirectory = "versions";
47
47
 
48
48
  public static final String TAG = "Capacitor-updater";
49
- public static final String pluginVersion = "4.0.0-alpha.26";
49
+ public static final String pluginVersion = "4.0.0-alpha.29";
50
50
 
51
51
  public SharedPreferences.Editor editor;
52
52
  public SharedPreferences prefs;
@@ -32,6 +32,7 @@ import java.text.SimpleDateFormat;
32
32
  import java.util.Date;
33
33
  import java.util.Iterator;
34
34
  import java.util.List;
35
+ import java.util.UUID;
35
36
 
36
37
  @CapacitorPlugin(name = "CapacitorUpdater")
37
38
  public class CapacitorUpdaterPlugin extends Plugin implements Application.ActivityLifecycleCallbacks {
@@ -87,7 +88,8 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
87
88
  this.implementation.prefs = this.prefs;
88
89
  this.implementation.editor = this.editor;
89
90
  this.implementation.versionOs = Build.VERSION.RELEASE;
90
- this.implementation.deviceID = Settings.Secure.getString(this.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
91
+ this.implementation.deviceID = this.prefs.getString("appUUID", UUID.randomUUID().toString());
92
+ this.editor.putString("appUUID", this.implementation.deviceID);
91
93
  Log.e(CapacitorUpdater.TAG, "init for device " + this.implementation.deviceID);
92
94
 
93
95
  this.autoDeleteFailed = this.getConfig().getBoolean("autoDeleteFailed", true);
@@ -234,7 +236,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
234
236
  @PluginMethod
235
237
  public void next(final PluginCall call) {
236
238
  final String id = call.getString("id");
237
-
239
+ if (id == null) {
240
+ Log.e(CapacitorUpdater.TAG, "Next called without id");
241
+ call.reject("Next called without id");
242
+ return;
243
+ }
238
244
  try {
239
245
  Log.i(CapacitorUpdater.TAG, "Setting next active id " + id);
240
246
  if (!this.implementation.setNextBundle(id)) {
@@ -252,7 +258,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
252
258
  @PluginMethod
253
259
  public void set(final PluginCall call) {
254
260
  final String id = call.getString("id");
255
-
261
+ if (id == null) {
262
+ Log.e(CapacitorUpdater.TAG, "Set called without id");
263
+ call.reject("Set called without id");
264
+ return;
265
+ }
256
266
  try {
257
267
  Log.i(CapacitorUpdater.TAG, "Setting active bundle " + id);
258
268
  if (!this.implementation.set(id)) {
@@ -271,6 +281,11 @@ public class CapacitorUpdaterPlugin extends Plugin implements Application.Activi
271
281
  @PluginMethod
272
282
  public void delete(final PluginCall call) {
273
283
  final String id = call.getString("id");
284
+ if (id == null) {
285
+ Log.e(CapacitorUpdater.TAG, "missing id");
286
+ call.reject("missing id");
287
+ return;
288
+ }
274
289
  Log.i(CapacitorUpdater.TAG, "Deleting id: " + id);
275
290
  try {
276
291
  final Boolean res = this.implementation.delete(id);
package/dist/docs.json CHANGED
@@ -28,12 +28,12 @@
28
28
  },
29
29
  {
30
30
  "name": "download",
31
- "signature": "(options: { url: string; version?: string; }) => Promise<BundleInfo>",
31
+ "signature": "(options: { url: string; version: string; }) => Promise<BundleInfo>",
32
32
  "parameters": [
33
33
  {
34
34
  "name": "options",
35
35
  "docs": "",
36
- "type": "{ url: string; version?: string | undefined; }"
36
+ "type": "{ url: string; version: string; }"
37
37
  }
38
38
  ],
39
39
  "returns": "Promise<BundleInfo>",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  {
50
50
  "name": "param",
51
- "text": "version (optional) set the version code/name of this bundle/version"
51
+ "text": "version set the version code/name of this bundle/version"
52
52
  },
53
53
  {
54
54
  "name": "example",
@@ -442,7 +442,7 @@
442
442
  "text": "2.3.0"
443
443
  }
444
444
  ],
445
- "docs": "Listen for update event in the App, let you know when update is ready to install at next app start",
445
+ "docs": "Listen for update fail event in the App, let you know when update hs fail to install at next app start",
446
446
  "complexTypes": [
447
447
  "PluginListenerHandle",
448
448
  "UpdateFailedListener"
@@ -141,12 +141,12 @@ export interface CapacitorUpdaterPlugin {
141
141
  *
142
142
  * @returns {Promise<BundleInfo>} The {@link BundleInfo} for the specified version.
143
143
  * @param url The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a github tag, any other place you've hosted your bundle.)
144
- * @param version (optional) set the version code/name of this bundle/version
144
+ * @param version set the version code/name of this bundle/version
145
145
  * @example https://example.com/versions/{version}/dist.zip
146
146
  */
147
147
  download(options: {
148
148
  url: string;
149
- version?: string;
149
+ version: string;
150
150
  }): Promise<BundleInfo>;
151
151
  /**
152
152
  * Set the next bundle to be used when the app is reloaded.
@@ -264,7 +264,7 @@ export interface CapacitorUpdaterPlugin {
264
264
  */
265
265
  addListener(eventName: 'majorAvailable', listenerFunc: MajorAvailableListener): Promise<PluginListenerHandle> & PluginListenerHandle;
266
266
  /**
267
- * Listen for update event in the App, let you know when update is ready to install at next app start
267
+ * Listen for update fail event in the App, let you know when update hs fail to install at next app start
268
268
  *
269
269
  * @since 2.3.0
270
270
  */
@@ -148,7 +148,7 @@ extension CustomError: LocalizedError {
148
148
 
149
149
  public let TAG = "✨ Capacitor-updater:";
150
150
  public let CAP_SERVER_PATH = "serverBasePath"
151
- public let pluginVersion = "4.0.0-alpha.26"
151
+ public let pluginVersion = "4.0.0-alpha.29"
152
152
  public var statsUrl = ""
153
153
  public var appId = ""
154
154
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
@@ -30,12 +30,12 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
30
30
  } catch {
31
31
  print("\(self.implementation.TAG) Cannot get version native \(currentVersionNative)")
32
32
  }
33
- autoDeleteFailed = getConfigValue("autoDeleteFailed") as? Bool ?? false
34
- autoDeletePrevious = getConfigValue("autoDeletePrevious") as? Bool ?? false
35
- updateUrl = getConfigValue("updateUrl") as? String ?? CapacitorUpdaterPlugin.updateUrlDefault
36
- autoUpdate = getConfigValue("autoUpdate") as? Bool ?? false
37
- appReadyTimeout = getConfigValue("appReadyTimeout") as? Int ?? 10000
38
- resetWhenUpdate = getConfigValue("resetWhenUpdate") as? Bool ?? true
33
+ autoDeleteFailed = getConfig().getBoolean("autoDeleteFailed", false)
34
+ autoDeletePrevious = getConfig().getBoolean("autoDeletePrevious", false)
35
+ updateUrl = getConfig().getString("updateUrl") ?? CapacitorUpdaterPlugin.updateUrlDefault
36
+ autoUpdate = getConfig().getBoolean("autoUpdate", false)
37
+ appReadyTimeout = getConfig().getInt("appReadyTimeout", 10000)
38
+ resetWhenUpdate = getConfig().getBoolean("resetWhenUpdate", true)
39
39
 
40
40
  implementation.appId = Bundle.main.bundleIdentifier ?? ""
41
41
  implementation.notifyDownload = notifyDownload
@@ -43,8 +43,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
43
43
  if (config?["appId"] != nil) {
44
44
  implementation.appId = config?["appId"] as! String
45
45
  }
46
- implementation.statsUrl = getConfigValue("statsUrl") as? String ?? CapacitorUpdaterPlugin.statsUrlDefault
47
-
46
+ implementation.statsUrl = getConfig().getString("statsUrl") ?? CapacitorUpdaterPlugin.updateUrlDefault
48
47
  if (resetWhenUpdate) {
49
48
  self.cleanupObsoleteVersions()
50
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "4.0.0-alpha.26",
3
+ "version": "4.0.0-alpha.29",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",