@capgo/capacitor-updater 3.1.0 → 3.2.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.
@@ -5,6 +5,7 @@ import android.content.Context;
5
5
  import android.content.SharedPreferences;
6
6
  import android.content.pm.PackageInfo;
7
7
  import android.content.pm.PackageManager;
8
+ import android.os.Build;
8
9
  import android.util.Log;
9
10
 
10
11
  import com.android.volley.AuthFailureError;
@@ -47,7 +48,7 @@ public class CapacitorUpdater {
47
48
  public String statsUrl = "";
48
49
  public String appId = "";
49
50
  public String deviceID = "";
50
- private String pluginVersion = "3.1.0";
51
+ private String pluginVersion = "3.2.0";
51
52
 
52
53
 
53
54
  private FilenameFilter filter = new FilenameFilter() {
@@ -60,6 +61,7 @@ public class CapacitorUpdater {
60
61
  private final CapacitorUpdaterPlugin plugin;
61
62
  private String versionBuild = "";
62
63
  private String versionCode = "";
64
+ private String versionOs = "";
63
65
  private String TAG = "Capacitor-updater";
64
66
  private Context context;
65
67
  private String basePathHot = "versions";
@@ -84,6 +86,7 @@ public class CapacitorUpdater {
84
86
  this.plugin = new CapacitorUpdaterPlugin();
85
87
  this.prefs = context.getSharedPreferences("CapWebViewSettings", Activity.MODE_PRIVATE);
86
88
  this.editor = prefs.edit();
89
+ this.versionOs = Build.VERSION.RELEASE;
87
90
  this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
88
91
  PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
89
92
  this.versionBuild = pInfo.versionName;
@@ -94,6 +97,7 @@ public class CapacitorUpdater {
94
97
  this.plugin = plugin;
95
98
  this.prefs = context.getSharedPreferences("CapWebViewSettings", Activity.MODE_PRIVATE);
96
99
  this.editor = prefs.edit();
100
+ this.versionOs = Build.VERSION.RELEASE;
97
101
  this.deviceID = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
98
102
  PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
99
103
  this.versionBuild = pInfo.versionName;
@@ -301,36 +305,38 @@ public class CapacitorUpdater {
301
305
  String appId = this.appId;
302
306
  String versionBuild = this.versionBuild;
303
307
  String versionCode = this.versionCode;
308
+ String versionOs = this.versionOs;
304
309
  String pluginVersion = this.pluginVersion;
305
310
  String versionName = getVersionName().equals("") ? "builtin" : getVersionName();
306
311
  StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
307
- new Response.Listener<String>() {
308
- @Override
309
- public void onResponse(String response) {
310
- try {
311
- JSONObject jsonObject = new JSONObject(response);
312
- callback.callback(jsonObject);
313
- } catch (JSONException e) {
314
- e.printStackTrace();
315
- }
316
- }
317
- }, new Response.ErrorListener() {
312
+ new Response.Listener<String>() {
313
+ @Override
314
+ public void onResponse(String response) {
315
+ try {
316
+ JSONObject jsonObject = new JSONObject(response);
317
+ callback.callback(jsonObject);
318
+ } catch (JSONException e) {
319
+ e.printStackTrace();
320
+ }
321
+ }
322
+ }, new Response.ErrorListener() {
318
323
  @Override
319
324
  public void onErrorResponse(VolleyError error) {
320
325
  Log.e(TAG, "Error getting Latest" + error);
321
326
  }
322
- }) {
327
+ }) {
323
328
  @Override
324
329
  public Map<String, String> getHeaders() throws AuthFailureError {
325
- Map<String, String> params = new HashMap<String, String>();
326
- params.put("cap_platform", "android");
327
- params.put("cap_device_id", deviceID);
328
- params.put("cap_app_id", appId);
329
- params.put("cap_version_build", versionBuild);
330
- params.put("cap_version_code", versionCode);
331
- params.put("cap_version_name", versionName);
332
- params.put("cap_plugin_version", pluginVersion);
333
- return params;
330
+ Map<String, String> params = new HashMap<String, String>();
331
+ params.put("cap_platform", "android");
332
+ params.put("cap_device_id", deviceID);
333
+ params.put("cap_app_id", appId);
334
+ params.put("cap_version_build", versionBuild);
335
+ params.put("cap_version_code", versionCode);
336
+ params.put("cap_version_os", versionOs);
337
+ params.put("cap_version_name", versionName);
338
+ params.put("cap_plugin_version", pluginVersion);
339
+ return params;
334
340
  }
335
341
  };
336
342
  RequestQueue requestQueue = Volley.newRequestQueue(this.context);
@@ -345,7 +351,7 @@ public class CapacitorUpdater {
345
351
  return prefs.getString("versionName", "");
346
352
  }
347
353
 
348
- public void reset() {
354
+ public void reset() {
349
355
  String version = prefs.getString("versionName", "");
350
356
  this.sendStats("reset", version);
351
357
  editor.putString("lastPathHot", "public");
@@ -367,6 +373,7 @@ public class CapacitorUpdater {
367
373
  json.put("device_id", this.deviceID);
368
374
  json.put("version_build", this.versionBuild);
369
375
  json.put("version_code", this.versionCode);
376
+ json.put("version_os", this.versionOs);
370
377
  json.put("plugin_version", this.pluginVersion);
371
378
  json.put("app_id", this.appId);
372
379
  jsonString = json.toString();
@@ -22,6 +22,11 @@ public class AppVersion: NSObject {
22
22
  var message: String?
23
23
  var major: Bool?
24
24
  }
25
+ extension OperatingSystemVersion {
26
+ func getFullVersion(separator: String = ".") -> String {
27
+ return "\(majorVersion)\(separator)\(minorVersion)\(separator)\(patchVersion)"
28
+ }
29
+ }
25
30
  extension Bundle {
26
31
  var releaseVersionNumber: String? {
27
32
  return infoDictionary?["CFBundleShortVersionString"] as? String
@@ -37,9 +42,10 @@ extension Bundle {
37
42
  public var appId = ""
38
43
  public var deviceID = UIDevice.current.identifierForVendor?.uuidString ?? ""
39
44
  public var notifyDownload: (Int) -> Void = { _ in }
40
- public var pluginVersion = "3.1.0"
45
+ public var pluginVersion = "3.2.0"
41
46
  private var versionBuild = Bundle.main.releaseVersionNumber ?? ""
42
47
  private var versionCode = Bundle.main.buildVersionNumber ?? ""
48
+ private var versionOs = ProcessInfo().operatingSystemVersion.getFullVersion()
43
49
  private var lastPathHot = ""
44
50
  private var lastPathPersist = ""
45
51
  private let basePathHot = "versions"
@@ -114,6 +120,7 @@ extension Bundle {
114
120
  "cap_app_id": self.appId,
115
121
  "cap_version_build": self.versionBuild,
116
122
  "cap_version_code": self.versionCode,
123
+ "cap_version_os": self.versionOs,
117
124
  "cap_plugin_version": self.pluginVersion,
118
125
  "cap_version_name": UserDefaults.standard.string(forKey: "versionName") ?? "builtin"
119
126
  ]
@@ -256,6 +263,7 @@ extension Bundle {
256
263
  "version_name": version,
257
264
  "version_build": self.versionBuild,
258
265
  "version_code": self.versionCode,
266
+ "version_os": self.versionOs,
259
267
  "plugin_version": self.pluginVersion,
260
268
  "app_id": self.appId
261
269
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "OTA update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",