native-update-capacitor 0.0.0-stage → 4.4.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/AI-INTEGRATION-GUIDE.md +578 -0
- package/LICENSE +25 -0
- package/NativeUpdate.podspec +19 -0
- package/README.md +574 -2
- package/android/build.gradle +125 -0
- package/android/consumer-rules.pro +9 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/manifest-additions.xml +28 -0
- package/android/proguard-rules.pro +26 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +13 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +159 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +314 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +406 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +48 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +343 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +236 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/JsonOptional.kt +26 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +1249 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +404 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +107 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +240 -0
- package/android/variables.gradle +5 -0
- package/cli/commands/backend-create.js +623 -0
- package/cli/commands/bundle-create.js +145 -0
- package/cli/commands/bundle-sign.js +64 -0
- package/cli/commands/bundle-verify.js +58 -0
- package/cli/commands/flutter-patch.js +107 -0
- package/cli/commands/init.js +146 -0
- package/cli/commands/keys-generate.js +58 -0
- package/cli/commands/monitor.js +89 -0
- package/cli/commands/remote-shared.js +264 -0
- package/cli/commands/remote.js +634 -0
- package/cli/commands/server-start.js +96 -0
- package/cli/index.js +625 -0
- package/cli/package.json +21 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +194 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +5 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +137 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +154 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +163 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +58 -0
- package/dist/esm/app-update/app-update-checker.js +227 -0
- package/dist/esm/app-update/app-update-installer.d.ts +20 -0
- package/dist/esm/app-update/app-update-installer.js +134 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +198 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +99 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +6 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +138 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +11 -0
- package/dist/esm/background-update/background-scheduler.d.ts +63 -0
- package/dist/esm/background-update/background-scheduler.js +332 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +2 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +88 -0
- package/dist/esm/config/support.d.ts +9 -0
- package/dist/esm/config/support.js +9 -0
- package/dist/esm/core/analytics.d.ts +83 -0
- package/dist/esm/core/analytics.js +151 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +274 -0
- package/dist/esm/core/config.d.ts +69 -0
- package/dist/esm/core/config.js +107 -0
- package/dist/esm/core/errors.d.ts +56 -0
- package/dist/esm/core/errors.js +85 -0
- package/dist/esm/core/event-emitter.d.ts +30 -0
- package/dist/esm/core/event-emitter.js +80 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +108 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +153 -0
- package/dist/esm/core/plugin-manager.d.ts +88 -0
- package/dist/esm/core/plugin-manager.js +224 -0
- package/dist/esm/core/security.d.ts +123 -0
- package/dist/esm/core/security.js +361 -0
- package/dist/esm/core/update-check.d.ts +121 -0
- package/dist/esm/core/update-check.js +127 -0
- package/dist/esm/definitions.d.ts +872 -0
- package/dist/esm/definitions.js +104 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/live-update/bundle-manager.d.ts +102 -0
- package/dist/esm/live-update/bundle-manager.js +344 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +77 -0
- package/dist/esm/live-update/delta-processor.d.ts +84 -0
- package/dist/esm/live-update/delta-processor.js +257 -0
- package/dist/esm/live-update/download-manager.d.ts +106 -0
- package/dist/esm/live-update/download-manager.js +412 -0
- package/dist/esm/live-update/rollout-checker.d.ts +86 -0
- package/dist/esm/live-update/rollout-checker.js +304 -0
- package/dist/esm/live-update/update-manager.d.ts +63 -0
- package/dist/esm/live-update/update-manager.js +321 -0
- package/dist/esm/live-update/version-manager.d.ts +93 -0
- package/dist/esm/live-update/version-manager.js +390 -0
- package/dist/esm/plugin.d.ts +3 -0
- package/dist/esm/plugin.js +848 -0
- package/dist/esm/security/crypto.d.ts +88 -0
- package/dist/esm/security/crypto.js +228 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +142 -0
- package/dist/esm/types/app-identity.d.ts +36 -0
- package/dist/esm/types/app-identity.js +1 -0
- package/dist/esm/types/rollout.d.ts +91 -0
- package/dist/esm/types/rollout.js +25 -0
- package/dist/esm/web.d.ts +130 -0
- package/dist/esm/web.js +981 -0
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.esm.js +1 -0
- package/dist/plugin.js +2 -0
- package/docs/CHANGELOG.md +1016 -0
- package/docs/KNOWN_LIMITATIONS.md +240 -0
- package/docs/MIGRATION.md +391 -0
- package/docs/protocol/CLIENT-PROTOCOL.md +199 -0
- package/docs/server-requirements.md +211 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +249 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +333 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +464 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +1286 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/NativeUpdatePlugin.m +53 -0
- package/ios/Plugin/NativeUpdatePlugin.swift +315 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- package/package.json +133 -4
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import WebKit
|
|
4
|
+
|
|
5
|
+
extension NativeUpdatePlugin {
|
|
6
|
+
|
|
7
|
+
// This method should be called by the Capacitor app during WebView setup
|
|
8
|
+
@objc public func configureWebView(for webView: WKWebView) {
|
|
9
|
+
// Check if there's an active bundle to load
|
|
10
|
+
if let activeBundleId = UserDefaults.standard.string(forKey: "native_update_active_bundle"),
|
|
11
|
+
let bundles = UserDefaults.standard.dictionary(forKey: "native_update_bundles"),
|
|
12
|
+
let bundleInfo = bundles[activeBundleId] as? [String: Any],
|
|
13
|
+
let extractedPath = bundleInfo["extractedPath"] as? String {
|
|
14
|
+
|
|
15
|
+
// Verify the bundle still exists
|
|
16
|
+
let bundleURL = URL(fileURLWithPath: extractedPath)
|
|
17
|
+
let indexURL = bundleURL.appendingPathComponent("index.html")
|
|
18
|
+
|
|
19
|
+
if FileManager.default.fileExists(atPath: indexURL.path) {
|
|
20
|
+
// Configure WebView to load from the active bundle
|
|
21
|
+
webView.loadFileURL(indexURL, allowingReadAccessTo: bundleURL)
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// If no active bundle or bundle doesn't exist, clear the active bundle
|
|
27
|
+
UserDefaults.standard.removeObject(forKey: "native_update_active_bundle")
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Helper method to get the current bundle's base URL
|
|
31
|
+
@objc public func getCurrentBundleURL() -> URL? {
|
|
32
|
+
if let activeBundleId = UserDefaults.standard.string(forKey: "native_update_active_bundle"),
|
|
33
|
+
let bundles = UserDefaults.standard.dictionary(forKey: "native_update_bundles"),
|
|
34
|
+
let bundleInfo = bundles[activeBundleId] as? [String: Any],
|
|
35
|
+
let extractedPath = bundleInfo["extractedPath"] as? String {
|
|
36
|
+
|
|
37
|
+
let bundleURL = URL(fileURLWithPath: extractedPath)
|
|
38
|
+
if FileManager.default.fileExists(atPath: bundleURL.path) {
|
|
39
|
+
return bundleURL
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return nil
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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(NativeUpdatePlugin, "NativeUpdate",
|
|
7
|
+
CAP_PLUGIN_METHOD(initialize, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(isInitialized, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(cleanup, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(configure, CAPPluginReturnPromise);
|
|
11
|
+
CAP_PLUGIN_METHOD(getSecurityInfo, CAPPluginReturnPromise);
|
|
12
|
+
|
|
13
|
+
// Live Update Methods
|
|
14
|
+
CAP_PLUGIN_METHOD(sync, CAPPluginReturnPromise);
|
|
15
|
+
CAP_PLUGIN_METHOD(download, CAPPluginReturnPromise);
|
|
16
|
+
CAP_PLUGIN_METHOD(set, CAPPluginReturnPromise);
|
|
17
|
+
CAP_PLUGIN_METHOD(reload, CAPPluginReturnPromise);
|
|
18
|
+
CAP_PLUGIN_METHOD(reset, CAPPluginReturnPromise);
|
|
19
|
+
CAP_PLUGIN_METHOD(current, CAPPluginReturnPromise);
|
|
20
|
+
CAP_PLUGIN_METHOD(list, CAPPluginReturnPromise);
|
|
21
|
+
CAP_PLUGIN_METHOD(delete, CAPPluginReturnPromise);
|
|
22
|
+
CAP_PLUGIN_METHOD(notifyAppReady, CAPPluginReturnPromise);
|
|
23
|
+
CAP_PLUGIN_METHOD(getLatest, CAPPluginReturnPromise);
|
|
24
|
+
CAP_PLUGIN_METHOD(getAppIdentity, CAPPluginReturnPromise);
|
|
25
|
+
CAP_PLUGIN_METHOD(setChannel, CAPPluginReturnPromise);
|
|
26
|
+
CAP_PLUGIN_METHOD(setUpdateUrl, CAPPluginReturnPromise);
|
|
27
|
+
CAP_PLUGIN_METHOD(validateUpdate, CAPPluginReturnPromise);
|
|
28
|
+
CAP_PLUGIN_METHOD(cancelDownload, CAPPluginReturnPromise);
|
|
29
|
+
CAP_PLUGIN_METHOD(cancelAllDownloads, CAPPluginReturnPromise);
|
|
30
|
+
CAP_PLUGIN_METHOD(isDownloading, CAPPluginReturnPromise);
|
|
31
|
+
CAP_PLUGIN_METHOD(getActiveDownloadCount, CAPPluginReturnPromise);
|
|
32
|
+
|
|
33
|
+
// App Update Methods
|
|
34
|
+
CAP_PLUGIN_METHOD(getAppUpdateInfo, CAPPluginReturnPromise);
|
|
35
|
+
CAP_PLUGIN_METHOD(performImmediateUpdate, CAPPluginReturnPromise);
|
|
36
|
+
CAP_PLUGIN_METHOD(startFlexibleUpdate, CAPPluginReturnPromise);
|
|
37
|
+
CAP_PLUGIN_METHOD(completeFlexibleUpdate, CAPPluginReturnPromise);
|
|
38
|
+
CAP_PLUGIN_METHOD(openAppStore, CAPPluginReturnPromise);
|
|
39
|
+
|
|
40
|
+
// App Review Methods
|
|
41
|
+
CAP_PLUGIN_METHOD(requestReview, CAPPluginReturnPromise);
|
|
42
|
+
CAP_PLUGIN_METHOD(canRequestReview, CAPPluginReturnPromise);
|
|
43
|
+
|
|
44
|
+
// Background Update Methods
|
|
45
|
+
CAP_PLUGIN_METHOD(enableBackgroundUpdates, CAPPluginReturnPromise);
|
|
46
|
+
CAP_PLUGIN_METHOD(disableBackgroundUpdates, CAPPluginReturnPromise);
|
|
47
|
+
CAP_PLUGIN_METHOD(getBackgroundUpdateStatus, CAPPluginReturnPromise);
|
|
48
|
+
CAP_PLUGIN_METHOD(scheduleBackgroundCheck, CAPPluginReturnPromise);
|
|
49
|
+
CAP_PLUGIN_METHOD(triggerBackgroundCheck, CAPPluginReturnPromise);
|
|
50
|
+
CAP_PLUGIN_METHOD(setNotificationPreferences, CAPPluginReturnPromise);
|
|
51
|
+
CAP_PLUGIN_METHOD(getNotificationPermissions, CAPPluginReturnPromise);
|
|
52
|
+
CAP_PLUGIN_METHOD(requestNotificationPermissions, CAPPluginReturnPromise);
|
|
53
|
+
)
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
|
|
4
|
+
@objc(NativeUpdatePlugin)
|
|
5
|
+
public class NativeUpdatePlugin: CAPPlugin {
|
|
6
|
+
private var liveUpdatePlugin: LiveUpdatePlugin!
|
|
7
|
+
private var appUpdatePlugin: AppUpdatePlugin!
|
|
8
|
+
private var appReviewPlugin: AppReviewPlugin!
|
|
9
|
+
private var backgroundUpdatePlugin: BackgroundUpdatePlugin!
|
|
10
|
+
private var securityManager: SecurityManager!
|
|
11
|
+
private var isInitialized = false
|
|
12
|
+
|
|
13
|
+
override public func load() {
|
|
14
|
+
super.load()
|
|
15
|
+
|
|
16
|
+
// Initialize sub-plugins
|
|
17
|
+
liveUpdatePlugin = LiveUpdatePlugin(plugin: self)
|
|
18
|
+
appUpdatePlugin = AppUpdatePlugin(plugin: self)
|
|
19
|
+
appReviewPlugin = AppReviewPlugin(plugin: self)
|
|
20
|
+
backgroundUpdatePlugin = BackgroundUpdatePlugin()
|
|
21
|
+
securityManager = SecurityManager()
|
|
22
|
+
backgroundUpdatePlugin.load()
|
|
23
|
+
backgroundUpdatePlugin.configureProviders(
|
|
24
|
+
appUpdate: { [weak self] in await self?.appUpdatePlugin.getAppUpdateInfoAsync() },
|
|
25
|
+
liveUpdate: { [weak self] in await self?.liveUpdatePlugin.getLatestVersionAsync() },
|
|
26
|
+
eventListener: { [weak self] event, data in self?.notifyListeners(event, data: data) }
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// Set up listeners
|
|
30
|
+
liveUpdatePlugin.setProgressListener { [weak self] progress in
|
|
31
|
+
self?.notifyListeners("downloadProgress", data: progress)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
liveUpdatePlugin.setStateChangeListener { [weak self] state in
|
|
35
|
+
self?.notifyListeners("updateStateChanged", data: state)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Set up app update event listener
|
|
39
|
+
appUpdatePlugin.setEventListener { [weak self] eventName, data in
|
|
40
|
+
self?.notifyListeners(eventName, data: data)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Boot-time integrity re-verify + crash-loop auto-rollback. Runs
|
|
44
|
+
// before any host-app code touches the WebView so a tampered or
|
|
45
|
+
// crash-looping bundle never gets a chance to load. Signature
|
|
46
|
+
// re-verify runs again after configure() when the publicKey
|
|
47
|
+
// arrives from the host app; checksum re-verify here is
|
|
48
|
+
// sufficient to catch most tampering.
|
|
49
|
+
liveUpdatePlugin.verifyActiveBundleOnBoot()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@objc func initialize(_ call: CAPPluginCall) {
|
|
53
|
+
do {
|
|
54
|
+
guard !isInitialized else {
|
|
55
|
+
call.reject("Configuration is locked after initialization; call reset() first")
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
guard let config = configuration(from: call) else {
|
|
59
|
+
call.reject("Configuration object is required")
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
try applyConfiguration(config)
|
|
63
|
+
isInitialized = true
|
|
64
|
+
call.resolve()
|
|
65
|
+
} catch {
|
|
66
|
+
call.reject("Initialization failed", error.localizedDescription)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@objc func isInitialized(_ call: CAPPluginCall) {
|
|
71
|
+
call.resolve(["initialized": isInitialized])
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc func cleanup(_ call: CAPPluginCall) {
|
|
75
|
+
liveUpdatePlugin.cleanup()
|
|
76
|
+
// CAPACITOR-SDK-WORKAROUND (assumes Capacitor 8.x):
|
|
77
|
+
// We cannot manufacture a synthetic CAPPluginCall to forward into
|
|
78
|
+
// backgroundUpdatePlugin.disableBackgroundUpdates(_:) because
|
|
79
|
+
// CAPPluginCall(callbackId:options:success:error:) is `internal`
|
|
80
|
+
// in the public Capacitor SDK — referencing it produces a
|
|
81
|
+
// compile error against the shipped framework. The internal
|
|
82
|
+
// `disableBackgroundUpdatesInternal()` shim wraps the same
|
|
83
|
+
// teardown logic and is the ONLY entry point that doesn't
|
|
84
|
+
// require a CAPPluginCall.
|
|
85
|
+
//
|
|
86
|
+
// Revisit on every Capacitor major bump: if the constructor
|
|
87
|
+
// becomes public, replace the shim with a real synthetic call.
|
|
88
|
+
// Tracked in docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md (item I2).
|
|
89
|
+
backgroundUpdatePlugin.disableBackgroundUpdatesInternal()
|
|
90
|
+
call.resolve()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@objc func configure(_ call: CAPPluginCall) {
|
|
94
|
+
// Accept BOTH documented shapes (v3.1.3):
|
|
95
|
+
// configure({ config: PluginInitConfig }) — wrapped
|
|
96
|
+
// initialize(PluginInitConfig) — flat (top-level keys)
|
|
97
|
+
// configure(UpdateConfig) — nested sections
|
|
98
|
+
// Before this fix only the wrapped shape reached native, so the
|
|
99
|
+
// flat initialize() every consumer uses configured NOTHING here.
|
|
100
|
+
guard !isInitialized else {
|
|
101
|
+
call.reject("Configuration is locked after initialization; call reset() first")
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
guard let config = configuration(from: call) else {
|
|
105
|
+
call.reject("Configuration object is required")
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
do {
|
|
110
|
+
try applyConfiguration(config)
|
|
111
|
+
isInitialized = true
|
|
112
|
+
call.resolve()
|
|
113
|
+
} catch {
|
|
114
|
+
call.reject("Configuration failed", error.localizedDescription)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private func configuration(from call: CAPPluginCall) -> [String: Any]? {
|
|
119
|
+
call.getObject("config").map { $0 as [String: Any] } ?? (call.options as? [String: Any])
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private func applyConfiguration(_ config: [String: Any]) throws {
|
|
123
|
+
try securityManager.configure(config)
|
|
124
|
+
if let live = Self.normalizeLiveUpdateConfig(from: config) { try liveUpdatePlugin.configure(live) }
|
|
125
|
+
if let value = config["appUpdate"] as? [String: Any] { try appUpdatePlugin.configure(value) }
|
|
126
|
+
if let value = config["appReview"] as? [String: Any] { try appReviewPlugin.configure(value) }
|
|
127
|
+
if let value = config["backgroundUpdate"] as? [String: Any] { try backgroundUpdatePlugin.configure(value) }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// Normalize a flat PluginInitConfig (serverUrl/baseUrl, apiKey, appId,
|
|
131
|
+
/// channel, publicKey at the top level) into the liveUpdate config shape
|
|
132
|
+
/// the sub-plugin reads. Returns nil when the payload carries no
|
|
133
|
+
/// live-update fields at all.
|
|
134
|
+
private static func buildFlatLiveUpdateConfig(from config: [String: Any]) -> [String: Any]? {
|
|
135
|
+
let serverUrl = (config["serverUrl"] as? String) ?? (config["baseUrl"] as? String)
|
|
136
|
+
let apiKey = config["apiKey"] as? String
|
|
137
|
+
if serverUrl == nil && apiKey == nil {
|
|
138
|
+
return nil
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var liveUpdate: [String: Any] = [:]
|
|
142
|
+
if let serverUrl = serverUrl { liveUpdate["serverUrl"] = serverUrl }
|
|
143
|
+
if let apiKey = apiKey { liveUpdate["apiKey"] = apiKey }
|
|
144
|
+
if let appId = config["appId"] as? String { liveUpdate["appId"] = appId }
|
|
145
|
+
if let channel = config["channel"] as? String { liveUpdate["channel"] = channel }
|
|
146
|
+
if let publicKey = config["publicKey"] as? String { liveUpdate["publicKey"] = publicKey }
|
|
147
|
+
if let requireSignature = config["requireSignature"] as? Bool { liveUpdate["requireSignature"] = requireSignature }
|
|
148
|
+
if let allowUnsigned = config["allowUnsignedDevelopmentUpdates"] as? Bool {
|
|
149
|
+
liveUpdate["allowUnsignedDevelopmentUpdates"] = allowUnsigned
|
|
150
|
+
}
|
|
151
|
+
if let maxBundleSize = config["maxBundleSize"] as? NSNumber { liveUpdate["maxBundleSize"] = maxBundleSize }
|
|
152
|
+
if let maxUncompressedBundleSize = config["maxUncompressedBundleSize"] as? NSNumber {
|
|
153
|
+
liveUpdate["maxUncompressedBundleSize"] = maxUncompressedBundleSize
|
|
154
|
+
}
|
|
155
|
+
if let enableDeltaUpdates = config["enableDeltaUpdates"] as? Bool {
|
|
156
|
+
liveUpdate["enableDeltaUpdates"] = enableDeltaUpdates
|
|
157
|
+
}
|
|
158
|
+
if let allowedHosts = config["allowedHosts"] as? [String] { liveUpdate["allowedHosts"] = allowedHosts }
|
|
159
|
+
if let security = config["security"] as? [String: Any] { liveUpdate["security"] = security }
|
|
160
|
+
return liveUpdate
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private static func normalizeLiveUpdateConfig(from config: [String: Any]) -> [String: Any]? {
|
|
164
|
+
guard var liveUpdate = (config["liveUpdate"] as? [String: Any]) ?? buildFlatLiveUpdateConfig(from: config) else {
|
|
165
|
+
return nil
|
|
166
|
+
}
|
|
167
|
+
if liveUpdate["security"] == nil { liveUpdate["security"] = config["security"] }
|
|
168
|
+
if liveUpdate["publicKey"] == nil { liveUpdate["publicKey"] = config["publicKey"] }
|
|
169
|
+
if liveUpdate["requireSignature"] == nil { liveUpdate["requireSignature"] = config["requireSignature"] }
|
|
170
|
+
if liveUpdate["allowUnsignedDevelopmentUpdates"] == nil {
|
|
171
|
+
liveUpdate["allowUnsignedDevelopmentUpdates"] = config["allowUnsignedDevelopmentUpdates"]
|
|
172
|
+
}
|
|
173
|
+
if liveUpdate["maxUncompressedBundleSize"] == nil {
|
|
174
|
+
liveUpdate["maxUncompressedBundleSize"] = config["maxUncompressedBundleSize"]
|
|
175
|
+
}
|
|
176
|
+
if liveUpdate["enableDeltaUpdates"] == nil {
|
|
177
|
+
liveUpdate["enableDeltaUpdates"] = config["enableDeltaUpdates"]
|
|
178
|
+
}
|
|
179
|
+
return liveUpdate
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@objc func getSecurityInfo(_ call: CAPPluginCall) {
|
|
183
|
+
call.resolve(securityManager.getSecurityInfo())
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// MARK: - Live Update Methods
|
|
187
|
+
|
|
188
|
+
@objc func sync(_ call: CAPPluginCall) {
|
|
189
|
+
liveUpdatePlugin.sync(call)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@objc func download(_ call: CAPPluginCall) {
|
|
193
|
+
liveUpdatePlugin.download(call)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@objc func set(_ call: CAPPluginCall) {
|
|
197
|
+
liveUpdatePlugin.set(call)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@objc func reload(_ call: CAPPluginCall) {
|
|
201
|
+
liveUpdatePlugin.reload(call)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@objc func reset(_ call: CAPPluginCall) {
|
|
205
|
+
liveUpdatePlugin.reset(call)
|
|
206
|
+
isInitialized = false
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@objc func current(_ call: CAPPluginCall) {
|
|
210
|
+
liveUpdatePlugin.current(call)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@objc func list(_ call: CAPPluginCall) {
|
|
214
|
+
liveUpdatePlugin.list(call)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@objc func delete(_ call: CAPPluginCall) {
|
|
218
|
+
liveUpdatePlugin.delete(call)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@objc func notifyAppReady(_ call: CAPPluginCall) {
|
|
222
|
+
liveUpdatePlugin.notifyAppReady(call)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@objc func getLatest(_ call: CAPPluginCall) {
|
|
226
|
+
liveUpdatePlugin.getLatest(call)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@objc func getAppIdentity(_ call: CAPPluginCall) {
|
|
230
|
+
liveUpdatePlugin.getAppIdentity(call)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@objc func setChannel(_ call: CAPPluginCall) {
|
|
234
|
+
liveUpdatePlugin.setChannel(call)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
@objc func setUpdateUrl(_ call: CAPPluginCall) {
|
|
238
|
+
liveUpdatePlugin.setUpdateUrl(call)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
@objc func validateUpdate(_ call: CAPPluginCall) {
|
|
242
|
+
liveUpdatePlugin.validateUpdate(call)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@objc func cancelDownload(_ call: CAPPluginCall) { liveUpdatePlugin.cancelDownload(call) }
|
|
246
|
+
@objc func cancelAllDownloads(_ call: CAPPluginCall) { liveUpdatePlugin.cancelAllDownloads(call) }
|
|
247
|
+
@objc func isDownloading(_ call: CAPPluginCall) { liveUpdatePlugin.isDownloading(call) }
|
|
248
|
+
@objc func getActiveDownloadCount(_ call: CAPPluginCall) { liveUpdatePlugin.getActiveDownloadCount(call) }
|
|
249
|
+
|
|
250
|
+
// MARK: - App Update Methods
|
|
251
|
+
|
|
252
|
+
@objc func getAppUpdateInfo(_ call: CAPPluginCall) {
|
|
253
|
+
appUpdatePlugin.getAppUpdateInfo(call)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
@objc func performImmediateUpdate(_ call: CAPPluginCall) {
|
|
257
|
+
appUpdatePlugin.performImmediateUpdate(call)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@objc func startFlexibleUpdate(_ call: CAPPluginCall) {
|
|
261
|
+
appUpdatePlugin.startFlexibleUpdate(call)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
@objc func completeFlexibleUpdate(_ call: CAPPluginCall) {
|
|
265
|
+
appUpdatePlugin.completeFlexibleUpdate(call)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@objc func openAppStore(_ call: CAPPluginCall) {
|
|
269
|
+
appUpdatePlugin.openAppStore(call)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// MARK: - App Review Methods
|
|
273
|
+
|
|
274
|
+
@objc func requestReview(_ call: CAPPluginCall) {
|
|
275
|
+
appReviewPlugin.requestReview(call)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
@objc func canRequestReview(_ call: CAPPluginCall) {
|
|
279
|
+
appReviewPlugin.canRequestReview(call)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// MARK: - Background Update Methods
|
|
283
|
+
|
|
284
|
+
@objc func enableBackgroundUpdates(_ call: CAPPluginCall) {
|
|
285
|
+
backgroundUpdatePlugin.enableBackgroundUpdates(call)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@objc func disableBackgroundUpdates(_ call: CAPPluginCall) {
|
|
289
|
+
backgroundUpdatePlugin.disableBackgroundUpdates(call)
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@objc func getBackgroundUpdateStatus(_ call: CAPPluginCall) {
|
|
293
|
+
backgroundUpdatePlugin.getBackgroundUpdateStatus(call)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@objc func scheduleBackgroundCheck(_ call: CAPPluginCall) {
|
|
297
|
+
backgroundUpdatePlugin.scheduleBackgroundCheck(call)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@objc func triggerBackgroundCheck(_ call: CAPPluginCall) {
|
|
301
|
+
backgroundUpdatePlugin.triggerBackgroundCheck(call)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
@objc func setNotificationPreferences(_ call: CAPPluginCall) {
|
|
305
|
+
backgroundUpdatePlugin.setNotificationPreferences(call)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@objc func getNotificationPermissions(_ call: CAPPluginCall) {
|
|
309
|
+
backgroundUpdatePlugin.getNotificationPermissions(call)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
@objc func requestNotificationPermissions(_ call: CAPPluginCall) {
|
|
313
|
+
backgroundUpdatePlugin.requestNotificationPermissions(call)
|
|
314
|
+
}
|
|
315
|
+
}
|