@capgo/capacitor-updater 6.1.34 → 6.2.1-beta.1

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.
@@ -16,6 +16,5 @@ Pod::Spec.new do |s|
16
16
  s.dependency 'SSZipArchive'
17
17
  s.dependency 'Alamofire'
18
18
  s.dependency 'Version'
19
- s.dependency 'SwiftyRSA'
20
19
  s.swift_version = '5.1'
21
20
  end
@@ -53,7 +53,7 @@ public class CapacitorUpdaterPlugin extends Plugin {
53
53
  private static final String channelUrlDefault =
54
54
  "https://api.capgo.app/channel_self";
55
55
 
56
- private final String PLUGIN_VERSION = "6.1.34";
56
+ private final String PLUGIN_VERSION = "6.2.0";
57
57
  private static final String DELAY_CONDITION_PREFERENCES = "";
58
58
 
59
59
  private SharedPreferences.Editor editor;
@@ -1148,6 +1148,37 @@ public class CapacitorUpdaterPlugin extends Plugin {
1148
1148
  return;
1149
1149
  }
1150
1150
 
1151
+ final String latestVersionName = res.getString("version");
1152
+
1153
+ if ("builtin".equals(latestVersionName)) {
1154
+ Log.i(CapacitorUpdater.TAG, "Latest version is builtin");
1155
+ if (CapacitorUpdaterPlugin.this.implementation.directUpdate) {
1156
+ Log.i(
1157
+ CapacitorUpdater.TAG,
1158
+ "Direct update to builtin version"
1159
+ );
1160
+ this._reset(false);
1161
+ CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
1162
+ "Updated to builtin version",
1163
+ latestVersionName,
1164
+ CapacitorUpdaterPlugin.this.implementation.getCurrentBundle(),
1165
+ false
1166
+ );
1167
+ } else {
1168
+ Log.i(CapacitorUpdater.TAG, "Setting next bundle to builtin");
1169
+ CapacitorUpdaterPlugin.this.implementation.setNextBundle(
1170
+ BundleInfo.ID_BUILTIN
1171
+ );
1172
+ CapacitorUpdaterPlugin.this.endBackGroundTaskWithNotif(
1173
+ "Next update will be to builtin version",
1174
+ latestVersionName,
1175
+ current,
1176
+ false
1177
+ );
1178
+ }
1179
+ return;
1180
+ }
1181
+
1151
1182
  if (
1152
1183
  !res.has("url") ||
1153
1184
  !CapacitorUpdaterPlugin.this.isValidURL(res.getString("url"))
@@ -1161,7 +1192,6 @@ public class CapacitorUpdaterPlugin extends Plugin {
1161
1192
  );
1162
1193
  return;
1163
1194
  }
1164
- final String latestVersionName = res.getString("version");
1165
1195
 
1166
1196
  if (
1167
1197
  latestVersionName != null &&
@@ -8,7 +8,6 @@ import Foundation
8
8
  import SSZipArchive
9
9
  import Alamofire
10
10
  import zlib
11
- import SwiftyRSA
12
11
  import CryptoKit
13
12
 
14
13
  extension Collection {
@@ -7,16 +7,43 @@
7
7
  import Foundation
8
8
  import Capacitor
9
9
  import Version
10
- import SwiftyRSA
11
10
 
12
11
  /**
13
12
  * Please read the Capacitor iOS Plugin Development Guide
14
13
  * here: https://capacitorjs.com/docs/plugins/ios
15
14
  */
16
15
  @objc(CapacitorUpdaterPlugin)
17
- public class CapacitorUpdaterPlugin: CAPPlugin {
16
+ public class CapacitorUpdaterPlugin: CAPPlugin, CAPBridgedPlugin {
17
+ public let identifier = "CapacitorUpdaterPlugin"
18
+ public let jsName = "CapacitorUpdater"
19
+ public let pluginMethods: [CAPPluginMethod] = [
20
+ CAPPluginMethod(name: "download", returnType: CAPPluginReturnPromise),
21
+ CAPPluginMethod(name: "setUpdateUrl", returnType: CAPPluginReturnPromise),
22
+ CAPPluginMethod(name: "setStatsUrl", returnType: CAPPluginReturnPromise),
23
+ CAPPluginMethod(name: "setChannelUrl", returnType: CAPPluginReturnPromise),
24
+ CAPPluginMethod(name: "set", returnType: CAPPluginReturnPromise),
25
+ CAPPluginMethod(name: "list", returnType: CAPPluginReturnPromise),
26
+ CAPPluginMethod(name: "delete", returnType: CAPPluginReturnPromise),
27
+ CAPPluginMethod(name: "reset", returnType: CAPPluginReturnPromise),
28
+ CAPPluginMethod(name: "current", returnType: CAPPluginReturnPromise),
29
+ CAPPluginMethod(name: "reload", returnType: CAPPluginReturnPromise),
30
+ CAPPluginMethod(name: "notifyAppReady", returnType: CAPPluginReturnPromise),
31
+ CAPPluginMethod(name: "setDelay", returnType: CAPPluginReturnPromise),
32
+ CAPPluginMethod(name: "setMultiDelay", returnType: CAPPluginReturnPromise),
33
+ CAPPluginMethod(name: "cancelDelay", returnType: CAPPluginReturnPromise),
34
+ CAPPluginMethod(name: "getLatest", returnType: CAPPluginReturnPromise),
35
+ CAPPluginMethod(name: "setChannel", returnType: CAPPluginReturnPromise),
36
+ CAPPluginMethod(name: "unsetChannel", returnType: CAPPluginReturnPromise),
37
+ CAPPluginMethod(name: "getChannel", returnType: CAPPluginReturnPromise),
38
+ CAPPluginMethod(name: "setCustomId", returnType: CAPPluginReturnPromise),
39
+ CAPPluginMethod(name: "getDeviceId", returnType: CAPPluginReturnPromise),
40
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise),
41
+ CAPPluginMethod(name: "next", returnType: CAPPluginReturnPromise),
42
+ CAPPluginMethod(name: "isAutoUpdateEnabled", returnType: CAPPluginReturnPromise),
43
+ CAPPluginMethod(name: "getBuiltinVersion", returnType: CAPPluginReturnPromise),
44
+ ]
18
45
  public var implementation = CapacitorUpdater()
19
- private let PLUGIN_VERSION: String = "6.1.34"
46
+ private let PLUGIN_VERSION: String = "6.2.0"
20
47
  static let updateUrlDefault = "https://api.capgo.app/updates"
21
48
  static let statsUrlDefault = "https://api.capgo.app/stats"
22
49
  static let channelUrlDefault = "https://api.capgo.app/channel_self"
@@ -696,6 +723,19 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
696
723
  self.endBackGroundTaskWithNotif(msg: res.message ?? "", latestVersionName: res.version, current: current, error: true)
697
724
  return
698
725
  }
726
+ if res.version == "builtin" {
727
+ print("\(self.implementation.TAG) Latest version is builtin")
728
+ if self.directUpdate {
729
+ print("\(self.implementation.TAG) Direct update to builtin version")
730
+ _ = self._reset(toLastSuccessful: false)
731
+ self.endBackGroundTaskWithNotif(msg: "Updated to builtin version", latestVersionName: res.version, current: self.implementation.getCurrentBundle(), error: false)
732
+ } else {
733
+ print("\(self.implementation.TAG) Setting next bundle to builtin")
734
+ _ = self.implementation.setNextBundle(next: BundleInfo.ID_BUILTIN)
735
+ self.endBackGroundTaskWithNotif(msg: "Next update will be to builtin version", latestVersionName: res.version, current: current, error: false)
736
+ }
737
+ return
738
+ }
699
739
  let sessionKey = res.sessionKey ?? ""
700
740
  guard let downloadUrl = URL(string: res.url) else {
701
741
  print("\(self.implementation.TAG) Error no url or wrong format")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-updater",
3
- "version": "6.1.34",
3
+ "version": "6.2.1-beta.1",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Live update for capacitor apps",
6
6
  "main": "dist/plugin.cjs.js",
@@ -1,10 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- //! Project version number for Plugin.
4
- FOUNDATION_EXPORT double PluginVersionNumber;
5
-
6
- //! Project version string for Plugin.
7
- FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
-
9
- // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
-
@@ -1,31 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <Capacitor/Capacitor.h>
3
-
4
- // Define the plugin using the CAP_PLUGIN Macro, and
5
- // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
- CAP_PLUGIN(CapacitorUpdaterPlugin, "CapacitorUpdater",
7
- CAP_PLUGIN_METHOD(download, CAPPluginReturnPromise);
8
- CAP_PLUGIN_METHOD(setUpdateUrl, CAPPluginReturnPromise);
9
- CAP_PLUGIN_METHOD(setStatsUrl, CAPPluginReturnPromise);
10
- CAP_PLUGIN_METHOD(setChannelUrl, CAPPluginReturnPromise);
11
- CAP_PLUGIN_METHOD(set, CAPPluginReturnPromise);
12
- CAP_PLUGIN_METHOD(list, CAPPluginReturnPromise);
13
- CAP_PLUGIN_METHOD(delete, CAPPluginReturnPromise);
14
- CAP_PLUGIN_METHOD(reset, CAPPluginReturnPromise);
15
- CAP_PLUGIN_METHOD(current, CAPPluginReturnPromise);
16
- CAP_PLUGIN_METHOD(reload, CAPPluginReturnPromise);
17
- CAP_PLUGIN_METHOD(notifyAppReady, CAPPluginReturnPromise);
18
- CAP_PLUGIN_METHOD(setDelay, CAPPluginReturnPromise);
19
- CAP_PLUGIN_METHOD(setMultiDelay, CAPPluginReturnPromise);
20
- CAP_PLUGIN_METHOD(cancelDelay, CAPPluginReturnPromise);
21
- CAP_PLUGIN_METHOD(getLatest, CAPPluginReturnPromise);
22
- CAP_PLUGIN_METHOD(setChannel, CAPPluginReturnPromise);
23
- CAP_PLUGIN_METHOD(unsetChannel, CAPPluginReturnPromise);
24
- CAP_PLUGIN_METHOD(getChannel, CAPPluginReturnPromise);
25
- CAP_PLUGIN_METHOD(setCustomId, CAPPluginReturnPromise);
26
- CAP_PLUGIN_METHOD(getDeviceId, CAPPluginReturnPromise);
27
- CAP_PLUGIN_METHOD(getPluginVersion, CAPPluginReturnPromise);
28
- CAP_PLUGIN_METHOD(next, CAPPluginReturnPromise);
29
- CAP_PLUGIN_METHOD(isAutoUpdateEnabled, CAPPluginReturnPromise);
30
- CAP_PLUGIN_METHOD(getBuiltinVersion, CAPPluginReturnPromise);
31
- )