@capawesome/capacitor-live-update 6.8.0 → 6.9.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.
- package/CapawesomeCapacitorLiveUpdate.podspec +2 -2
- package/README.md +429 -20
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +851 -261
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +35 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +56 -11
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +273 -38
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePreferences.java +52 -3
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetChannelsResponseItem.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/api/GetLatestBundleResponse.java +11 -2
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/DownloadBundleProgressEvent.java +32 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/events/NextBundleSetEvent.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/FetchChannelsOptions.java +38 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetConfigOptions.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SyncOptions.java +4 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/ChannelResult.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchChannelsResult.java +28 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/FetchLatestBundleResult.java +8 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetBlockedBundlesResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetConfigResult.java +40 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/GetDownloadedBundlesResult.java +27 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/IsSyncingResult.java +26 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/results/ReadyResult.java +32 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/interfaces/DownloadProgressCallback.java +5 -0
- package/dist/docs.json +853 -50
- package/dist/esm/definitions.d.ts +411 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +10 -2
- package/dist/esm/web.js +24 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +24 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +24 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift +25 -0
- package/ios/Plugin/Classes/Events/NextBundleSetEvent.swift +16 -0
- package/ios/Plugin/Classes/Options/FetchChannelsOptions.swift +26 -0
- package/ios/Plugin/Classes/Options/SetConfigOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/SyncOptions.swift +4 -0
- package/ios/Plugin/Classes/Results/ChannelResult.swift +19 -0
- package/ios/Plugin/Classes/Results/FetchChannelsResult.swift +16 -0
- package/ios/Plugin/Classes/Results/{FetchLatestBundle.swift → FetchLatestBundleResult.swift} +6 -1
- package/ios/Plugin/Classes/Results/GetBlockedBundlesResult.swift +16 -0
- package/ios/Plugin/Classes/Results/GetConfigResult.swift +19 -0
- package/ios/Plugin/Classes/Results/GetDownloadedBundlesResult.swift +16 -0
- package/ios/Plugin/Classes/Results/IsSyncingResult.swift +16 -0
- package/ios/Plugin/Classes/Results/ReadyResult.swift +22 -0
- package/ios/Plugin/LiveUpdate.swift +423 -145
- package/ios/Plugin/LiveUpdateConfig.swift +3 -0
- package/ios/Plugin/LiveUpdateHttpClient.swift +21 -4
- package/ios/Plugin/LiveUpdatePlugin.swift +174 -14
- package/ios/Plugin/LiveUpdatePreferences.swift +54 -12
- package/ios/Plugin/Protocols/Api/GetChannelsResponseItem.swift +4 -0
- package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +1 -0
- package/package.json +5 -5
- package/ios/Plugin/LiveUpdatePlugin.h +0 -10
- package/ios/Plugin/LiveUpdatePlugin.m +0 -27
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
public struct LiveUpdateConfig {
|
|
2
2
|
var appId: String?
|
|
3
|
+
var autoBlockRolledBackBundles = false
|
|
3
4
|
var autoDeleteBundles = false
|
|
5
|
+
var autoUpdateStrategy = "none"
|
|
4
6
|
var defaultChannel: String?
|
|
5
7
|
var enabled = true
|
|
6
8
|
var httpTimeout = 60000
|
|
@@ -8,4 +10,5 @@ public struct LiveUpdateConfig {
|
|
|
8
10
|
var publicKey: String?
|
|
9
11
|
var readyTimeout = 10000
|
|
10
12
|
var resetOnUpdate = true
|
|
13
|
+
var serverDomain = "api.cloud.capawesome.io"
|
|
11
14
|
}
|
|
@@ -5,25 +5,39 @@ import Alamofire
|
|
|
5
5
|
public class LiveUpdateHttpClient: NSObject {
|
|
6
6
|
|
|
7
7
|
private let config: LiveUpdateConfig
|
|
8
|
+
private var deviceId: String?
|
|
8
9
|
|
|
9
10
|
public static func getChecksumFromResponse(response: HTTPURLResponse) -> String? {
|
|
10
|
-
|
|
11
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
12
|
+
return headers.first(where: { $0.key.lowercased() == "x-checksum" })?.value
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
public static func getSignatureFromResponse(response: HTTPURLResponse) -> String? {
|
|
14
|
-
|
|
16
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
17
|
+
return headers.first(where: { $0.key.lowercased() == "x-signature" })?.value
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
init(config: LiveUpdateConfig) {
|
|
18
21
|
self.config = config
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
public func
|
|
24
|
+
public func setDeviceId(_ deviceId: String) {
|
|
25
|
+
self.deviceId = deviceId
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public func download(url: URL, destination: @escaping DownloadRequest.Destination, callback: ((Progress) -> Void)?) async throws -> AFDownloadResponse<Data> {
|
|
22
29
|
var request = URLRequest(url: url)
|
|
23
30
|
request.httpMethod = HTTPMethod.get.rawValue
|
|
24
31
|
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
32
|
+
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
33
|
+
request.setValue(deviceId, forHTTPHeaderField: "X-Device-Id")
|
|
34
|
+
}
|
|
25
35
|
return try await withCheckedThrowingContinuation { continuation in
|
|
26
|
-
AF.download(request, to: destination).
|
|
36
|
+
AF.download(request, to: destination).downloadProgress { progress in
|
|
37
|
+
if let callback = callback {
|
|
38
|
+
callback(progress)
|
|
39
|
+
}
|
|
40
|
+
}.responseData(emptyResponseCodes: [200, 204, 205]) { response in
|
|
27
41
|
continuation.resume(returning: response)
|
|
28
42
|
}
|
|
29
43
|
}
|
|
@@ -33,6 +47,9 @@ public class LiveUpdateHttpClient: NSObject {
|
|
|
33
47
|
var request = URLRequest(url: url)
|
|
34
48
|
request.httpMethod = HTTPMethod.get.rawValue
|
|
35
49
|
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
50
|
+
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
51
|
+
request.setValue(deviceId, forHTTPHeaderField: "X-Device-Id")
|
|
52
|
+
}
|
|
36
53
|
return try await withCheckedThrowingContinuation { continuation in
|
|
37
54
|
AF.request(request).validate().responseDecodable(of: type) { response in
|
|
38
55
|
continuation.resume(returning: response)
|
|
@@ -6,18 +6,70 @@ import Capacitor
|
|
|
6
6
|
* here: https://capacitorjs.com/docs/plugins/ios
|
|
7
7
|
*/
|
|
8
8
|
@objc(LiveUpdatePlugin)
|
|
9
|
-
public class LiveUpdatePlugin: CAPPlugin {
|
|
9
|
+
public class LiveUpdatePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
10
|
public static let tag = "LiveUpdate"
|
|
11
|
-
public static let version = "6.
|
|
11
|
+
public static let version = "6.9.0"
|
|
12
12
|
public static let userDefaultsPrefix = "CapawesomeLiveUpdate" // DO NOT CHANGE
|
|
13
13
|
|
|
14
|
+
public let identifier = "LiveUpdatePlugin"
|
|
15
|
+
public let jsName = "LiveUpdate"
|
|
16
|
+
public let pluginMethods: [CAPPluginMethod] = [
|
|
17
|
+
CAPPluginMethod(name: "clearBlockedBundles", returnType: CAPPluginReturnPromise),
|
|
18
|
+
CAPPluginMethod(name: "deleteBundle", returnType: CAPPluginReturnPromise),
|
|
19
|
+
CAPPluginMethod(name: "downloadBundle", returnType: CAPPluginReturnPromise),
|
|
20
|
+
CAPPluginMethod(name: "fetchChannels", returnType: CAPPluginReturnPromise),
|
|
21
|
+
CAPPluginMethod(name: "fetchLatestBundle", returnType: CAPPluginReturnPromise),
|
|
22
|
+
CAPPluginMethod(name: "getBlockedBundles", returnType: CAPPluginReturnPromise),
|
|
23
|
+
CAPPluginMethod(name: "getBundle", returnType: CAPPluginReturnPromise),
|
|
24
|
+
CAPPluginMethod(name: "getBundles", returnType: CAPPluginReturnPromise),
|
|
25
|
+
CAPPluginMethod(name: "getChannel", returnType: CAPPluginReturnPromise),
|
|
26
|
+
CAPPluginMethod(name: "getConfig", returnType: CAPPluginReturnPromise),
|
|
27
|
+
CAPPluginMethod(name: "getDownloadedBundles", returnType: CAPPluginReturnPromise),
|
|
28
|
+
CAPPluginMethod(name: "getCurrentBundle", returnType: CAPPluginReturnPromise),
|
|
29
|
+
CAPPluginMethod(name: "getCustomId", returnType: CAPPluginReturnPromise),
|
|
30
|
+
CAPPluginMethod(name: "getDeviceId", returnType: CAPPluginReturnPromise),
|
|
31
|
+
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise),
|
|
32
|
+
CAPPluginMethod(name: "getVersionCode", returnType: CAPPluginReturnPromise),
|
|
33
|
+
CAPPluginMethod(name: "getVersionName", returnType: CAPPluginReturnPromise),
|
|
34
|
+
CAPPluginMethod(name: "isSyncing", returnType: CAPPluginReturnPromise),
|
|
35
|
+
CAPPluginMethod(name: "ready", returnType: CAPPluginReturnPromise),
|
|
36
|
+
CAPPluginMethod(name: "reload", returnType: CAPPluginReturnPromise),
|
|
37
|
+
CAPPluginMethod(name: "reset", returnType: CAPPluginReturnPromise),
|
|
38
|
+
CAPPluginMethod(name: "resetConfig", returnType: CAPPluginReturnPromise),
|
|
39
|
+
CAPPluginMethod(name: "setBundle", returnType: CAPPluginReturnPromise),
|
|
40
|
+
CAPPluginMethod(name: "setChannel", returnType: CAPPluginReturnPromise),
|
|
41
|
+
CAPPluginMethod(name: "setConfig", returnType: CAPPluginReturnPromise),
|
|
42
|
+
CAPPluginMethod(name: "setCustomId", returnType: CAPPluginReturnPromise),
|
|
43
|
+
CAPPluginMethod(name: "setNextBundle", returnType: CAPPluginReturnPromise),
|
|
44
|
+
CAPPluginMethod(name: "sync", returnType: CAPPluginReturnPromise)
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
private let eventDownloadBundleProgess = "downloadBundleProgress"
|
|
48
|
+
private let eventNextBundleSet = "nextBundleSet"
|
|
49
|
+
private let eventReloaded = "reloaded"
|
|
50
|
+
|
|
14
51
|
private var config: LiveUpdateConfig?
|
|
15
52
|
private var implementation: LiveUpdate?
|
|
16
|
-
private var syncInProgress = false
|
|
17
53
|
|
|
18
54
|
override public func load() {
|
|
19
55
|
self.config = liveUpdateConfig()
|
|
20
56
|
self.implementation = LiveUpdate(config: config!, plugin: self)
|
|
57
|
+
|
|
58
|
+
// Notify implementation about load
|
|
59
|
+
implementation?.handleLoad()
|
|
60
|
+
|
|
61
|
+
// Register for app resume notifications
|
|
62
|
+
NotificationCenter.default.addObserver(
|
|
63
|
+
self,
|
|
64
|
+
selector: #selector(handleAppWillEnterForeground),
|
|
65
|
+
name: UIApplication.willEnterForegroundNotification,
|
|
66
|
+
object: nil
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@objc func clearBlockedBundles(_ call: CAPPluginCall) {
|
|
71
|
+
implementation?.clearBlockedBundles()
|
|
72
|
+
resolveCall(call)
|
|
21
73
|
}
|
|
22
74
|
|
|
23
75
|
@objc func deleteBundle(_ call: CAPPluginCall) {
|
|
@@ -62,9 +114,33 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
62
114
|
}
|
|
63
115
|
}
|
|
64
116
|
|
|
117
|
+
@objc func fetchChannels(_ call: CAPPluginCall) {
|
|
118
|
+
Task {
|
|
119
|
+
do {
|
|
120
|
+
guard let appId = config?.appId, !appId.isEmpty else {
|
|
121
|
+
call.reject(CustomError.appIdMissing.localizedDescription)
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let options = FetchChannelsOptions(call)
|
|
126
|
+
let result = try await implementation?.fetchChannels(options)
|
|
127
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
128
|
+
self.resolveCall(call, result)
|
|
129
|
+
}
|
|
130
|
+
} catch {
|
|
131
|
+
rejectCall(call, error)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
65
136
|
@objc func fetchLatestBundle(_ call: CAPPluginCall) {
|
|
66
137
|
Task {
|
|
67
138
|
do {
|
|
139
|
+
guard let appId = config?.appId, !appId.isEmpty else {
|
|
140
|
+
call.reject(CustomError.appIdMissing.localizedDescription)
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
|
|
68
144
|
let options = FetchLatestBundleOptions(call)
|
|
69
145
|
let result = try await implementation?.fetchLatestBundle(options)
|
|
70
146
|
if let result = result?.toJSObject() as? JSObject {
|
|
@@ -76,6 +152,18 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
76
152
|
}
|
|
77
153
|
}
|
|
78
154
|
|
|
155
|
+
@objc func getBlockedBundles(_ call: CAPPluginCall) {
|
|
156
|
+
implementation?.getBlockedBundles(completion: { result, error in
|
|
157
|
+
if let error = error {
|
|
158
|
+
self.rejectCall(call, error)
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
162
|
+
self.resolveCall(call, result)
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
|
|
79
167
|
@objc func getBundle(_ call: CAPPluginCall) {
|
|
80
168
|
implementation?.getBundle(completion: { result, error in
|
|
81
169
|
if let error = error {
|
|
@@ -100,6 +188,18 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
100
188
|
})
|
|
101
189
|
}
|
|
102
190
|
|
|
191
|
+
@objc func getDownloadedBundles(_ call: CAPPluginCall) {
|
|
192
|
+
implementation?.getDownloadedBundles(completion: { result, error in
|
|
193
|
+
if let error = error {
|
|
194
|
+
self.rejectCall(call, error)
|
|
195
|
+
return
|
|
196
|
+
}
|
|
197
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
198
|
+
self.resolveCall(call, result)
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
103
203
|
@objc func getChannel(_ call: CAPPluginCall) {
|
|
104
204
|
implementation?.getChannel(completion: { result, error in
|
|
105
205
|
if let error = error {
|
|
@@ -112,6 +212,18 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
112
212
|
})
|
|
113
213
|
}
|
|
114
214
|
|
|
215
|
+
@objc func getConfig(_ call: CAPPluginCall) {
|
|
216
|
+
implementation?.getConfig(completion: { result, error in
|
|
217
|
+
if let error = error {
|
|
218
|
+
self.rejectCall(call, error)
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
222
|
+
self.resolveCall(call, result)
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
}
|
|
226
|
+
|
|
115
227
|
@objc func getCurrentBundle(_ call: CAPPluginCall) {
|
|
116
228
|
implementation?.getCurrentBundle(completion: { result, error in
|
|
117
229
|
if let error = error {
|
|
@@ -184,9 +296,28 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
184
296
|
})
|
|
185
297
|
}
|
|
186
298
|
|
|
299
|
+
@objc func isSyncing(_ call: CAPPluginCall) {
|
|
300
|
+
implementation?.isSyncing(completion: { result, error in
|
|
301
|
+
if let error = error {
|
|
302
|
+
self.rejectCall(call, error)
|
|
303
|
+
return
|
|
304
|
+
}
|
|
305
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
306
|
+
self.resolveCall(call, result)
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
|
|
187
311
|
@objc func ready(_ call: CAPPluginCall) {
|
|
188
|
-
implementation?.ready(
|
|
189
|
-
|
|
312
|
+
implementation?.ready(completion: { result, error in
|
|
313
|
+
if let error = error {
|
|
314
|
+
self.rejectCall(call, error)
|
|
315
|
+
return
|
|
316
|
+
}
|
|
317
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
318
|
+
self.resolveCall(call, result)
|
|
319
|
+
}
|
|
320
|
+
})
|
|
190
321
|
}
|
|
191
322
|
|
|
192
323
|
@objc func reload(_ call: CAPPluginCall) {
|
|
@@ -199,6 +330,11 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
199
330
|
resolveCall(call)
|
|
200
331
|
}
|
|
201
332
|
|
|
333
|
+
@objc func resetConfig(_ call: CAPPluginCall) {
|
|
334
|
+
implementation?.resetConfig()
|
|
335
|
+
resolveCall(call)
|
|
336
|
+
}
|
|
337
|
+
|
|
202
338
|
@objc func setBundle(_ call: CAPPluginCall) {
|
|
203
339
|
guard let bundleId = call.getString("bundleId") else {
|
|
204
340
|
call.reject(CustomError.bundleIdMissing.localizedDescription)
|
|
@@ -230,6 +366,12 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
230
366
|
})
|
|
231
367
|
}
|
|
232
368
|
|
|
369
|
+
@objc func setConfig(_ call: CAPPluginCall) {
|
|
370
|
+
let options = SetConfigOptions(call)
|
|
371
|
+
implementation?.setConfig(options)
|
|
372
|
+
resolveCall(call)
|
|
373
|
+
}
|
|
374
|
+
|
|
233
375
|
@objc func setCustomId(_ call: CAPPluginCall) {
|
|
234
376
|
guard let customId = call.getString("customId") else {
|
|
235
377
|
call.reject(CustomError.customIdMissing.localizedDescription)
|
|
@@ -262,35 +404,48 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
262
404
|
@objc func sync(_ call: CAPPluginCall) {
|
|
263
405
|
Task {
|
|
264
406
|
do {
|
|
265
|
-
guard let
|
|
407
|
+
guard let appId = config?.appId, !appId.isEmpty else {
|
|
266
408
|
call.reject(CustomError.appIdMissing.localizedDescription)
|
|
267
409
|
return
|
|
268
410
|
}
|
|
269
411
|
|
|
270
|
-
guard !syncInProgress else {
|
|
271
|
-
call.reject(CustomError.syncInProgress.localizedDescription)
|
|
272
|
-
return
|
|
273
|
-
}
|
|
274
|
-
syncInProgress = true
|
|
275
|
-
|
|
276
412
|
let options = SyncOptions(call)
|
|
277
413
|
let result = try await implementation?.sync(options)
|
|
278
|
-
self.syncInProgress = false
|
|
279
414
|
if let result = result?.toJSObject() as? JSObject {
|
|
280
415
|
resolveCall(call, result)
|
|
281
416
|
}
|
|
282
417
|
} catch {
|
|
283
|
-
self.syncInProgress = false
|
|
284
418
|
rejectCall(call, error)
|
|
285
419
|
}
|
|
286
420
|
}
|
|
287
421
|
}
|
|
288
422
|
|
|
423
|
+
func notifyDownloadBundleProgressListeners(_ event: DownloadBundleProgressEvent) {
|
|
424
|
+
if let event = event.toJSObject() as? JSObject {
|
|
425
|
+
notifyListeners(eventDownloadBundleProgess, data: event, retainUntilConsumed: false)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
func notifyNextBundleSetListeners(_ event: NextBundleSetEvent) {
|
|
430
|
+
notifyListeners(eventNextBundleSet, data: event.toJSObject(), retainUntilConsumed: false)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
func notifyReloadedListeners() {
|
|
434
|
+
let event = JSObject()
|
|
435
|
+
notifyListeners(eventReloaded, data: event, retainUntilConsumed: true)
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
@objc private func handleAppWillEnterForeground() {
|
|
439
|
+
implementation?.handleAppWillEnterForeground()
|
|
440
|
+
}
|
|
441
|
+
|
|
289
442
|
private func liveUpdateConfig() -> LiveUpdateConfig {
|
|
290
443
|
var config = LiveUpdateConfig()
|
|
291
444
|
|
|
292
445
|
config.appId = getConfig().getString("appId", config.appId)
|
|
446
|
+
config.autoBlockRolledBackBundles = getConfig().getBoolean("autoBlockRolledBackBundles", config.autoBlockRolledBackBundles)
|
|
293
447
|
config.autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.autoDeleteBundles)
|
|
448
|
+
config.autoUpdateStrategy = getConfig().getString("autoUpdateStrategy", config.autoUpdateStrategy) ?? config.autoUpdateStrategy
|
|
294
449
|
config.defaultChannel = getConfig().getString("defaultChannel", config.defaultChannel)
|
|
295
450
|
config.enabled = getConfig().getBoolean("enabled", config.enabled)
|
|
296
451
|
config.httpTimeout = getConfig().getInt("httpTimeout", config.httpTimeout)
|
|
@@ -298,6 +453,11 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
298
453
|
config.publicKey = getConfig().getString("publicKey", config.publicKey)
|
|
299
454
|
config.readyTimeout = getConfig().getInt("readyTimeout", config.readyTimeout)
|
|
300
455
|
config.resetOnUpdate = getConfig().getBoolean("resetOnUpdate", config.resetOnUpdate)
|
|
456
|
+
config.serverDomain = getConfig().getString("serverDomain", config.serverDomain) ?? config.serverDomain
|
|
457
|
+
// Map the deprecated `location` option to `serverDomain` if `serverDomain` was not explicitly set.
|
|
458
|
+
if config.serverDomain == "api.cloud.capawesome.io", config.location == "eu" {
|
|
459
|
+
config.serverDomain = "api.cloud.capawesome.eu"
|
|
460
|
+
}
|
|
301
461
|
|
|
302
462
|
return config
|
|
303
463
|
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
|
|
3
3
|
public class LiveUpdatePreferences: NSObject {
|
|
4
|
+
private let appIdKey = "appId" // DO NOT CHANGE
|
|
5
|
+
private let blockedBundleIdsKey = "blockedBundleIds" // DO NOT CHANGE
|
|
4
6
|
private let channelKey = "channel" // DO NOT CHANGE
|
|
5
7
|
private let customIdKey = "customId" // DO NOT CHANGE
|
|
6
|
-
private let
|
|
7
|
-
private let
|
|
8
|
+
private let lastVersionCodeKey = "lastVersionCode" // DO NOT CHANGE
|
|
9
|
+
private let lastVersionNameKey = "lastVersionName" // DO NOT CHANGE
|
|
10
|
+
private let previousBundleIdKey = "previousBundleIdKey" // DO NOT CHANGE
|
|
11
|
+
|
|
12
|
+
public func getAppId() -> String? {
|
|
13
|
+
return UserDefaults.standard.string(forKey: applyPrefix(to: appIdKey))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public func getBlockedBundleIds() -> String? {
|
|
17
|
+
return UserDefaults.standard.string(forKey: applyPrefix(to: blockedBundleIdsKey))
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
public func getChannel() -> String? {
|
|
10
21
|
return UserDefaults.standard.string(forKey: applyPrefix(to: channelKey))
|
|
@@ -14,12 +25,34 @@ public class LiveUpdatePreferences: NSObject {
|
|
|
14
25
|
return UserDefaults.standard.string(forKey: applyPrefix(to: customIdKey))
|
|
15
26
|
}
|
|
16
27
|
|
|
17
|
-
public func
|
|
18
|
-
return UserDefaults.standard.string(forKey: applyPrefix(to:
|
|
28
|
+
public func getLastVersionCode() -> String? {
|
|
29
|
+
return UserDefaults.standard.string(forKey: applyPrefix(to: lastVersionCodeKey))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public func getLastVersionName() -> String? {
|
|
33
|
+
return UserDefaults.standard.string(forKey: applyPrefix(to: lastVersionNameKey))
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public func getPreviousBundleId() -> String? {
|
|
37
|
+
return UserDefaults.standard.string(forKey: applyPrefix(to: previousBundleIdKey))
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public func setAppId(_ value: String?) {
|
|
41
|
+
if let value = value {
|
|
42
|
+
UserDefaults.standard.set(value, forKey: applyPrefix(to: appIdKey))
|
|
43
|
+
} else {
|
|
44
|
+
UserDefaults.standard.removeObject(forKey: applyPrefix(to: appIdKey))
|
|
45
|
+
}
|
|
46
|
+
UserDefaults.standard.synchronize()
|
|
19
47
|
}
|
|
20
48
|
|
|
21
|
-
public func
|
|
22
|
-
|
|
49
|
+
public func setBlockedBundleIds(_ value: String?) {
|
|
50
|
+
if let value = value {
|
|
51
|
+
UserDefaults.standard.set(value, forKey: applyPrefix(to: blockedBundleIdsKey))
|
|
52
|
+
} else {
|
|
53
|
+
UserDefaults.standard.removeObject(forKey: applyPrefix(to: blockedBundleIdsKey))
|
|
54
|
+
}
|
|
55
|
+
UserDefaults.standard.synchronize()
|
|
23
56
|
}
|
|
24
57
|
|
|
25
58
|
public func setChannel(_ value: String?) {
|
|
@@ -36,20 +69,29 @@ public class LiveUpdatePreferences: NSObject {
|
|
|
36
69
|
UserDefaults.standard.synchronize()
|
|
37
70
|
}
|
|
38
71
|
|
|
39
|
-
public func
|
|
72
|
+
public func setLastVersionCode(_ value: String?) {
|
|
73
|
+
if let value = value {
|
|
74
|
+
UserDefaults.standard.set(value, forKey: applyPrefix(to: lastVersionCodeKey))
|
|
75
|
+
} else {
|
|
76
|
+
UserDefaults.standard.removeObject(forKey: applyPrefix(to: lastVersionCodeKey))
|
|
77
|
+
}
|
|
78
|
+
UserDefaults.standard.synchronize()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public func setLastVersionName(_ value: String?) {
|
|
40
82
|
if let value = value {
|
|
41
|
-
UserDefaults.standard.set(value, forKey: applyPrefix(to:
|
|
83
|
+
UserDefaults.standard.set(value, forKey: applyPrefix(to: lastVersionNameKey))
|
|
42
84
|
} else {
|
|
43
|
-
UserDefaults.standard.removeObject(forKey: applyPrefix(to:
|
|
85
|
+
UserDefaults.standard.removeObject(forKey: applyPrefix(to: lastVersionNameKey))
|
|
44
86
|
}
|
|
45
87
|
UserDefaults.standard.synchronize()
|
|
46
88
|
}
|
|
47
89
|
|
|
48
|
-
public func
|
|
90
|
+
public func setPreviousBundleId(_ value: String?) {
|
|
49
91
|
if let value = value {
|
|
50
|
-
UserDefaults.standard.set(value, forKey: applyPrefix(to:
|
|
92
|
+
UserDefaults.standard.set(value, forKey: applyPrefix(to: previousBundleIdKey))
|
|
51
93
|
} else {
|
|
52
|
-
UserDefaults.standard.removeObject(forKey: applyPrefix(to:
|
|
94
|
+
UserDefaults.standard.removeObject(forKey: applyPrefix(to: previousBundleIdKey))
|
|
53
95
|
}
|
|
54
96
|
UserDefaults.standard.synchronize()
|
|
55
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-live-update",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"description": "Capacitor plugin to update your app remotely in real-time.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"prepublishOnly": "npm run build"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@capacitor/android": "6.
|
|
68
|
-
"@capacitor/cli": "6.
|
|
69
|
-
"@capacitor/core": "6.
|
|
67
|
+
"@capacitor/android": "6.2.1",
|
|
68
|
+
"@capacitor/cli": "6.2.1",
|
|
69
|
+
"@capacitor/core": "6.2.1",
|
|
70
70
|
"@capacitor/docgen": "0.3.0",
|
|
71
|
-
"@capacitor/ios": "6.
|
|
71
|
+
"@capacitor/ios": "6.2.1",
|
|
72
72
|
"@ionic/eslint-config": "0.3.0",
|
|
73
73
|
"@ionic/prettier-config": "2.0.0",
|
|
74
74
|
"@ionic/swiftlint-config": "1.1.2",
|
|
@@ -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,27 +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(LiveUpdatePlugin, "LiveUpdate",
|
|
7
|
-
CAP_PLUGIN_METHOD(deleteBundle, CAPPluginReturnPromise);
|
|
8
|
-
CAP_PLUGIN_METHOD(downloadBundle, CAPPluginReturnPromise);
|
|
9
|
-
CAP_PLUGIN_METHOD(fetchLatestBundle, CAPPluginReturnPromise);
|
|
10
|
-
CAP_PLUGIN_METHOD(getBundle, CAPPluginReturnPromise);
|
|
11
|
-
CAP_PLUGIN_METHOD(getBundles, CAPPluginReturnPromise);
|
|
12
|
-
CAP_PLUGIN_METHOD(getChannel, CAPPluginReturnPromise);
|
|
13
|
-
CAP_PLUGIN_METHOD(getCurrentBundle, CAPPluginReturnPromise);
|
|
14
|
-
CAP_PLUGIN_METHOD(getCustomId, CAPPluginReturnPromise);
|
|
15
|
-
CAP_PLUGIN_METHOD(getDeviceId, CAPPluginReturnPromise);
|
|
16
|
-
CAP_PLUGIN_METHOD(getNextBundle, CAPPluginReturnPromise);
|
|
17
|
-
CAP_PLUGIN_METHOD(getVersionCode, CAPPluginReturnPromise);
|
|
18
|
-
CAP_PLUGIN_METHOD(getVersionName, CAPPluginReturnPromise);
|
|
19
|
-
CAP_PLUGIN_METHOD(ready, CAPPluginReturnPromise);
|
|
20
|
-
CAP_PLUGIN_METHOD(reload, CAPPluginReturnPromise);
|
|
21
|
-
CAP_PLUGIN_METHOD(reset, CAPPluginReturnPromise);
|
|
22
|
-
CAP_PLUGIN_METHOD(setBundle, CAPPluginReturnPromise);
|
|
23
|
-
CAP_PLUGIN_METHOD(setChannel, CAPPluginReturnPromise);
|
|
24
|
-
CAP_PLUGIN_METHOD(setCustomId, CAPPluginReturnPromise);
|
|
25
|
-
CAP_PLUGIN_METHOD(setNextBundle, CAPPluginReturnPromise);
|
|
26
|
-
CAP_PLUGIN_METHOD(sync, CAPPluginReturnPromise);
|
|
27
|
-
)
|