@capawesome/capacitor-live-update 6.7.2 → 7.0.0-dev.1765885034
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 +3 -3
- package/Package.swift +32 -0
- package/README.md +419 -83
- package/android/build.gradle +12 -12
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +758 -273
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateConfig.java +29 -27
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdateHttpClient.java +40 -7
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +212 -68
- 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/GetLatestBundleResponse.java +27 -0
- 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/{results/GetBundleResult.java → events/NextBundleSetEvent.java} +9 -7
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/DownloadBundleOptions.java +16 -1
- 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/FetchLatestBundleResult.java +29 -1
- 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 +630 -103
- package/dist/esm/definitions.d.ts +365 -39
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +9 -2
- package/dist/esm/web.js +21 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +22 -3
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +22 -3
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Classes/Events/DownloadBundleProgressEvent.swift +25 -0
- package/ios/Plugin/Classes/{Results/GetBundleResult.swift → Events/NextBundleSetEvent.swift} +3 -3
- package/ios/Plugin/Classes/Options/DownloadBundleOptions.swift +7 -1
- package/ios/Plugin/Classes/Options/SetConfigOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/SyncOptions.swift +4 -0
- package/ios/Plugin/Classes/Results/{FetchLatestBundle.swift → FetchLatestBundleResult.swift} +16 -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 +370 -151
- package/ios/Plugin/LiveUpdateConfig.swift +4 -4
- package/ios/Plugin/LiveUpdateHttpClient.swift +10 -4
- package/ios/Plugin/LiveUpdatePlugin.swift +138 -35
- package/ios/Plugin/LiveUpdatePreferences.swift +56 -14
- package/ios/Plugin/Protocols/Api/GetLatestBundleResponse.swift +3 -0
- package/package.json +19 -20
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/classes/options/SetBundleOptions.java +0 -18
- package/ios/Plugin/Classes/Options/SetBundleOptions.swift +0 -14
- package/ios/Plugin/LiveUpdatePlugin.h +0 -10
- package/ios/Plugin/LiveUpdatePlugin.m +0 -27
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
var enabled = true
|
|
6
7
|
var httpTimeout = 60000
|
|
7
|
-
var location: String?
|
|
8
8
|
var publicKey: String?
|
|
9
|
-
var readyTimeout =
|
|
10
|
-
var
|
|
9
|
+
var readyTimeout = 0
|
|
10
|
+
var serverDomain = "api.cloud.capawesome.io"
|
|
11
11
|
}
|
|
@@ -7,23 +7,29 @@ public class LiveUpdateHttpClient: NSObject {
|
|
|
7
7
|
private let config: LiveUpdateConfig
|
|
8
8
|
|
|
9
9
|
public static func getChecksumFromResponse(response: HTTPURLResponse) -> String? {
|
|
10
|
-
|
|
10
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
11
|
+
return headers.first(where: { $0.key.lowercased() == "x-checksum" })?.value
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
public static func getSignatureFromResponse(response: HTTPURLResponse) -> String? {
|
|
14
|
-
|
|
15
|
+
guard let headers = response.allHeaderFields as? [String: String] else { return nil }
|
|
16
|
+
return headers.first(where: { $0.key.lowercased() == "x-signature" })?.value
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
init(config: LiveUpdateConfig) {
|
|
18
20
|
self.config = config
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
public func download(url: URL, destination: @escaping DownloadRequest.Destination) async throws -> AFDownloadResponse<Data> {
|
|
23
|
+
public func download(url: URL, destination: @escaping DownloadRequest.Destination, callback: ((Progress) -> Void)?) async throws -> AFDownloadResponse<Data> {
|
|
22
24
|
var request = URLRequest(url: url)
|
|
23
25
|
request.httpMethod = HTTPMethod.get.rawValue
|
|
24
26
|
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
25
27
|
return try await withCheckedThrowingContinuation { continuation in
|
|
26
|
-
AF.download(request, to: destination).
|
|
28
|
+
AF.download(request, to: destination).downloadProgress { progress in
|
|
29
|
+
if let callback = callback {
|
|
30
|
+
callback(progress)
|
|
31
|
+
}
|
|
32
|
+
}.responseData(emptyResponseCodes: [200, 204, 205]) { response in
|
|
27
33
|
continuation.resume(returning: response)
|
|
28
34
|
}
|
|
29
35
|
}
|
|
@@ -6,18 +6,67 @@ 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 = "
|
|
11
|
+
public static let version = "7.4.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: "fetchLatestBundle", returnType: CAPPluginReturnPromise),
|
|
21
|
+
CAPPluginMethod(name: "getBlockedBundles", returnType: CAPPluginReturnPromise),
|
|
22
|
+
CAPPluginMethod(name: "getBundles", returnType: CAPPluginReturnPromise),
|
|
23
|
+
CAPPluginMethod(name: "getChannel", returnType: CAPPluginReturnPromise),
|
|
24
|
+
CAPPluginMethod(name: "getConfig", returnType: CAPPluginReturnPromise),
|
|
25
|
+
CAPPluginMethod(name: "getDownloadedBundles", returnType: CAPPluginReturnPromise),
|
|
26
|
+
CAPPluginMethod(name: "getCurrentBundle", returnType: CAPPluginReturnPromise),
|
|
27
|
+
CAPPluginMethod(name: "getCustomId", returnType: CAPPluginReturnPromise),
|
|
28
|
+
CAPPluginMethod(name: "getDeviceId", returnType: CAPPluginReturnPromise),
|
|
29
|
+
CAPPluginMethod(name: "getNextBundle", returnType: CAPPluginReturnPromise),
|
|
30
|
+
CAPPluginMethod(name: "getVersionCode", returnType: CAPPluginReturnPromise),
|
|
31
|
+
CAPPluginMethod(name: "getVersionName", returnType: CAPPluginReturnPromise),
|
|
32
|
+
CAPPluginMethod(name: "isSyncing", returnType: CAPPluginReturnPromise),
|
|
33
|
+
CAPPluginMethod(name: "ready", returnType: CAPPluginReturnPromise),
|
|
34
|
+
CAPPluginMethod(name: "reload", returnType: CAPPluginReturnPromise),
|
|
35
|
+
CAPPluginMethod(name: "reset", returnType: CAPPluginReturnPromise),
|
|
36
|
+
CAPPluginMethod(name: "resetConfig", returnType: CAPPluginReturnPromise),
|
|
37
|
+
CAPPluginMethod(name: "setChannel", returnType: CAPPluginReturnPromise),
|
|
38
|
+
CAPPluginMethod(name: "setConfig", returnType: CAPPluginReturnPromise),
|
|
39
|
+
CAPPluginMethod(name: "setCustomId", returnType: CAPPluginReturnPromise),
|
|
40
|
+
CAPPluginMethod(name: "setNextBundle", returnType: CAPPluginReturnPromise),
|
|
41
|
+
CAPPluginMethod(name: "sync", returnType: CAPPluginReturnPromise)
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
private let eventDownloadBundleProgess = "downloadBundleProgress"
|
|
45
|
+
private let eventNextBundleSet = "nextBundleSet"
|
|
46
|
+
private let eventReloaded = "reloaded"
|
|
47
|
+
|
|
14
48
|
private var config: LiveUpdateConfig?
|
|
15
49
|
private var implementation: LiveUpdate?
|
|
16
|
-
private var syncInProgress = false
|
|
17
50
|
|
|
18
51
|
override public func load() {
|
|
19
52
|
self.config = liveUpdateConfig()
|
|
20
53
|
self.implementation = LiveUpdate(config: config!, plugin: self)
|
|
54
|
+
|
|
55
|
+
// Notify implementation about load
|
|
56
|
+
implementation?.handleLoad()
|
|
57
|
+
|
|
58
|
+
// Register for app resume notifications
|
|
59
|
+
NotificationCenter.default.addObserver(
|
|
60
|
+
self,
|
|
61
|
+
selector: #selector(handleAppWillEnterForeground),
|
|
62
|
+
name: UIApplication.willEnterForegroundNotification,
|
|
63
|
+
object: nil
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@objc func clearBlockedBundles(_ call: CAPPluginCall) {
|
|
68
|
+
implementation?.clearBlockedBundles()
|
|
69
|
+
resolveCall(call)
|
|
21
70
|
}
|
|
22
71
|
|
|
23
72
|
@objc func deleteBundle(_ call: CAPPluginCall) {
|
|
@@ -46,12 +95,13 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
46
95
|
return
|
|
47
96
|
}
|
|
48
97
|
let checksum = call.getString("checksum")
|
|
98
|
+
let signature = call.getString("signature")
|
|
49
99
|
guard let url = call.getString("url") else {
|
|
50
100
|
call.reject(CustomError.urlMissing.localizedDescription)
|
|
51
101
|
return
|
|
52
102
|
}
|
|
53
103
|
|
|
54
|
-
let options = DownloadBundleOptions(artifactType: artifactType, bundleId: bundleId, checksum: checksum, url: url)
|
|
104
|
+
let options = DownloadBundleOptions(artifactType: artifactType, bundleId: bundleId, checksum: checksum, signature: signature, url: url)
|
|
55
105
|
|
|
56
106
|
try await implementation?.downloadBundle(options)
|
|
57
107
|
self.resolveCall(call)
|
|
@@ -64,6 +114,11 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
64
114
|
@objc func fetchLatestBundle(_ call: CAPPluginCall) {
|
|
65
115
|
Task {
|
|
66
116
|
do {
|
|
117
|
+
guard let appId = config?.appId, !appId.isEmpty else {
|
|
118
|
+
call.reject(CustomError.appIdMissing.localizedDescription)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
|
|
67
122
|
let options = FetchLatestBundleOptions(call)
|
|
68
123
|
let result = try await implementation?.fetchLatestBundle(options)
|
|
69
124
|
if let result = result?.toJSObject() as? JSObject {
|
|
@@ -75,8 +130,8 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
75
130
|
}
|
|
76
131
|
}
|
|
77
132
|
|
|
78
|
-
@objc func
|
|
79
|
-
implementation?.
|
|
133
|
+
@objc func getBlockedBundles(_ call: CAPPluginCall) {
|
|
134
|
+
implementation?.getBlockedBundles(completion: { result, error in
|
|
80
135
|
if let error = error {
|
|
81
136
|
self.rejectCall(call, error)
|
|
82
137
|
return
|
|
@@ -99,6 +154,18 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
99
154
|
})
|
|
100
155
|
}
|
|
101
156
|
|
|
157
|
+
@objc func getDownloadedBundles(_ call: CAPPluginCall) {
|
|
158
|
+
implementation?.getDownloadedBundles(completion: { result, error in
|
|
159
|
+
if let error = error {
|
|
160
|
+
self.rejectCall(call, error)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
164
|
+
self.resolveCall(call, result)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
|
|
102
169
|
@objc func getChannel(_ call: CAPPluginCall) {
|
|
103
170
|
implementation?.getChannel(completion: { result, error in
|
|
104
171
|
if let error = error {
|
|
@@ -111,6 +178,18 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
111
178
|
})
|
|
112
179
|
}
|
|
113
180
|
|
|
181
|
+
@objc func getConfig(_ call: CAPPluginCall) {
|
|
182
|
+
implementation?.getConfig(completion: { result, error in
|
|
183
|
+
if let error = error {
|
|
184
|
+
self.rejectCall(call, error)
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
188
|
+
self.resolveCall(call, result)
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
|
|
114
193
|
@objc func getCurrentBundle(_ call: CAPPluginCall) {
|
|
115
194
|
implementation?.getCurrentBundle(completion: { result, error in
|
|
116
195
|
if let error = error {
|
|
@@ -183,9 +262,28 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
183
262
|
})
|
|
184
263
|
}
|
|
185
264
|
|
|
265
|
+
@objc func isSyncing(_ call: CAPPluginCall) {
|
|
266
|
+
implementation?.isSyncing(completion: { result, error in
|
|
267
|
+
if let error = error {
|
|
268
|
+
self.rejectCall(call, error)
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
272
|
+
self.resolveCall(call, result)
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
}
|
|
276
|
+
|
|
186
277
|
@objc func ready(_ call: CAPPluginCall) {
|
|
187
|
-
implementation?.ready(
|
|
188
|
-
|
|
278
|
+
implementation?.ready(completion: { result, error in
|
|
279
|
+
if let error = error {
|
|
280
|
+
self.rejectCall(call, error)
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
if let result = result?.toJSObject() as? JSObject {
|
|
284
|
+
self.resolveCall(call, result)
|
|
285
|
+
}
|
|
286
|
+
})
|
|
189
287
|
}
|
|
190
288
|
|
|
191
289
|
@objc func reload(_ call: CAPPluginCall) {
|
|
@@ -198,21 +296,9 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
198
296
|
resolveCall(call)
|
|
199
297
|
}
|
|
200
298
|
|
|
201
|
-
@objc func
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
let options = SetBundleOptions(bundleId: bundleId)
|
|
208
|
-
|
|
209
|
-
implementation?.setBundle(options, completion: { error in
|
|
210
|
-
if let error = error {
|
|
211
|
-
self.rejectCall(call, error)
|
|
212
|
-
return
|
|
213
|
-
}
|
|
214
|
-
self.resolveCall(call)
|
|
215
|
-
})
|
|
299
|
+
@objc func resetConfig(_ call: CAPPluginCall) {
|
|
300
|
+
implementation?.resetConfig()
|
|
301
|
+
resolveCall(call)
|
|
216
302
|
}
|
|
217
303
|
|
|
218
304
|
@objc func setChannel(_ call: CAPPluginCall) {
|
|
@@ -229,6 +315,12 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
229
315
|
})
|
|
230
316
|
}
|
|
231
317
|
|
|
318
|
+
@objc func setConfig(_ call: CAPPluginCall) {
|
|
319
|
+
let options = SetConfigOptions(call)
|
|
320
|
+
implementation?.setConfig(options)
|
|
321
|
+
resolveCall(call)
|
|
322
|
+
}
|
|
323
|
+
|
|
232
324
|
@objc func setCustomId(_ call: CAPPluginCall) {
|
|
233
325
|
guard let customId = call.getString("customId") else {
|
|
234
326
|
call.reject(CustomError.customIdMissing.localizedDescription)
|
|
@@ -261,42 +353,53 @@ public class LiveUpdatePlugin: CAPPlugin {
|
|
|
261
353
|
@objc func sync(_ call: CAPPluginCall) {
|
|
262
354
|
Task {
|
|
263
355
|
do {
|
|
264
|
-
guard let
|
|
356
|
+
guard let appId = config?.appId, !appId.isEmpty else {
|
|
265
357
|
call.reject(CustomError.appIdMissing.localizedDescription)
|
|
266
358
|
return
|
|
267
359
|
}
|
|
268
360
|
|
|
269
|
-
guard !syncInProgress else {
|
|
270
|
-
call.reject(CustomError.syncInProgress.localizedDescription)
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
syncInProgress = true
|
|
274
|
-
|
|
275
361
|
let options = SyncOptions(call)
|
|
276
362
|
let result = try await implementation?.sync(options)
|
|
277
|
-
self.syncInProgress = false
|
|
278
363
|
if let result = result?.toJSObject() as? JSObject {
|
|
279
364
|
resolveCall(call, result)
|
|
280
365
|
}
|
|
281
366
|
} catch {
|
|
282
|
-
self.syncInProgress = false
|
|
283
367
|
rejectCall(call, error)
|
|
284
368
|
}
|
|
285
369
|
}
|
|
286
370
|
}
|
|
287
371
|
|
|
372
|
+
func notifyDownloadBundleProgressListeners(_ event: DownloadBundleProgressEvent) {
|
|
373
|
+
if let event = event.toJSObject() as? JSObject {
|
|
374
|
+
notifyListeners(eventDownloadBundleProgess, data: event, retainUntilConsumed: false)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
func notifyNextBundleSetListeners(_ event: NextBundleSetEvent) {
|
|
379
|
+
notifyListeners(eventNextBundleSet, data: event.toJSObject(), retainUntilConsumed: false)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
func notifyReloadedListeners() {
|
|
383
|
+
let event = JSObject()
|
|
384
|
+
notifyListeners(eventReloaded, data: event, retainUntilConsumed: true)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
@objc private func handleAppWillEnterForeground() {
|
|
388
|
+
implementation?.handleAppWillEnterForeground()
|
|
389
|
+
}
|
|
390
|
+
|
|
288
391
|
private func liveUpdateConfig() -> LiveUpdateConfig {
|
|
289
392
|
var config = LiveUpdateConfig()
|
|
290
393
|
|
|
291
394
|
config.appId = getConfig().getString("appId", config.appId)
|
|
395
|
+
config.autoBlockRolledBackBundles = getConfig().getBoolean("autoBlockRolledBackBundles", config.autoBlockRolledBackBundles)
|
|
292
396
|
config.autoDeleteBundles = getConfig().getBoolean("autoDeleteBundles", config.autoDeleteBundles)
|
|
397
|
+
config.autoUpdateStrategy = getConfig().getString("autoUpdateStrategy", config.autoUpdateStrategy) ?? config.autoUpdateStrategy
|
|
293
398
|
config.defaultChannel = getConfig().getString("defaultChannel", config.defaultChannel)
|
|
294
|
-
config.enabled = getConfig().getBoolean("enabled", config.enabled)
|
|
295
399
|
config.httpTimeout = getConfig().getInt("httpTimeout", config.httpTimeout)
|
|
296
|
-
config.location = getConfig().getString("location", config.location)
|
|
297
400
|
config.publicKey = getConfig().getString("publicKey", config.publicKey)
|
|
298
401
|
config.readyTimeout = getConfig().getInt("readyTimeout", config.readyTimeout)
|
|
299
|
-
config.
|
|
402
|
+
config.serverDomain = getConfig().getString("serverDomain", config.serverDomain) ?? config.serverDomain
|
|
300
403
|
|
|
301
404
|
return config
|
|
302
405
|
}
|
|
@@ -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))
|
|
@@ -13,13 +24,35 @@ public class LiveUpdatePreferences: NSObject {
|
|
|
13
24
|
public func getCustomId() -> String? {
|
|
14
25
|
return UserDefaults.standard.string(forKey: applyPrefix(to: customIdKey))
|
|
15
26
|
}
|
|
16
|
-
|
|
17
|
-
public func
|
|
18
|
-
return UserDefaults.standard.string(forKey: applyPrefix(to:
|
|
27
|
+
|
|
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?) {
|
|
@@ -35,21 +68,30 @@ public class LiveUpdatePreferences: NSObject {
|
|
|
35
68
|
UserDefaults.standard.set(value, forKey: applyPrefix(to: customIdKey))
|
|
36
69
|
UserDefaults.standard.synchronize()
|
|
37
70
|
}
|
|
38
|
-
|
|
39
|
-
public func
|
|
71
|
+
|
|
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": "
|
|
3
|
+
"version": "7.0.0-dev.1765885034",
|
|
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",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"android/build.gradle",
|
|
12
12
|
"dist/",
|
|
13
13
|
"ios/Plugin/",
|
|
14
|
-
"CapawesomeCapacitorLiveUpdate.podspec"
|
|
14
|
+
"CapawesomeCapacitorLiveUpdate.podspec",
|
|
15
|
+
"Package.swift"
|
|
15
16
|
],
|
|
16
17
|
"author": "Robin Genz <mail@robingenz.dev>",
|
|
17
18
|
"license": "MIT",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
57
58
|
"swiftlint": "node-swiftlint",
|
|
58
59
|
"docgen": "docgen --api LiveUpdatePlugin --output-readme README.md --output-json dist/docs.json",
|
|
59
|
-
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.
|
|
60
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
60
61
|
"clean": "rimraf ./dist",
|
|
61
62
|
"watch": "tsc --watch",
|
|
62
63
|
"version": "node scripts/sync-plugin-version.mjs",
|
|
@@ -64,26 +65,24 @@
|
|
|
64
65
|
"prepublishOnly": "npm run build"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|
|
67
|
-
"@capacitor/android": "
|
|
68
|
-
"@capacitor/cli": "
|
|
69
|
-
"@capacitor/core": "
|
|
70
|
-
"@capacitor/docgen": "0.3.
|
|
71
|
-
"@capacitor/ios": "
|
|
72
|
-
"@ionic/eslint-config": "0.
|
|
73
|
-
"@ionic/
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"prettier": "2.6.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"typescript": "4.1.5"
|
|
68
|
+
"@capacitor/android": "8.0.0",
|
|
69
|
+
"@capacitor/cli": "8.0.0",
|
|
70
|
+
"@capacitor/core": "8.0.0",
|
|
71
|
+
"@capacitor/docgen": "0.3.1",
|
|
72
|
+
"@capacitor/ios": "8.0.0",
|
|
73
|
+
"@ionic/eslint-config": "0.4.0",
|
|
74
|
+
"@ionic/swiftlint-config": "2.0.0",
|
|
75
|
+
"eslint": "8.57.0",
|
|
76
|
+
"prettier": "3.4.2",
|
|
77
|
+
"prettier-plugin-java": "2.6.7",
|
|
78
|
+
"rimraf": "6.1.2",
|
|
79
|
+
"rollup": "4.53.3",
|
|
80
|
+
"swiftlint": "2.0.0",
|
|
81
|
+
"typescript": "5.9.3"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@capacitor/core": "
|
|
84
|
+
"@capacitor/core": ">=8.0.0"
|
|
85
85
|
},
|
|
86
|
-
"prettier": "@ionic/prettier-config",
|
|
87
86
|
"swiftlint": "@ionic/swiftlint-config",
|
|
88
87
|
"eslintConfig": {
|
|
89
88
|
"extends": "@ionic/eslint-config/recommended"
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -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
|
-
)
|