native-update-capacitor 4.4.6 → 5.0.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.
@@ -50,16 +50,12 @@ public class BackgroundUpdatePlugin: CAPPlugin {
50
50
  notificationManager = BackgroundNotificationManager(plugin: self)
51
51
 
52
52
  // Register background task
53
- if #available(iOS 13.0, *) {
54
- BGTaskScheduler.shared.register(forTaskWithIdentifier: backgroundTaskIdentifier, using: nil) { task in
55
- guard let refreshTask = task as? BGAppRefreshTask else {
56
- // Force-casting here would crash the host app process
57
- // if Apple ever delivers a different concrete type.
58
- task.setTaskCompleted(success: false)
59
- return
60
- }
61
- self.handleBackgroundTask(task: refreshTask)
53
+ BGTaskScheduler.shared.register(forTaskWithIdentifier: backgroundTaskIdentifier, using: nil) { task in
54
+ guard let refreshTask = task as? BGAppRefreshTask else {
55
+ task.setTaskCompleted(success: false)
56
+ return
62
57
  }
58
+ self.handleBackgroundTask(task: refreshTask)
63
59
  }
64
60
  }
65
61
 
@@ -88,7 +84,7 @@ public class BackgroundUpdatePlugin: CAPPlugin {
88
84
  if config.enabled {
89
85
  scheduleBackgroundTask(interval: config.checkInterval)
90
86
  } else {
91
- disableBackgroundUpdates()
87
+ stopBackgroundUpdates()
92
88
  }
93
89
 
94
90
  call.resolve()
@@ -98,7 +94,7 @@ public class BackgroundUpdatePlugin: CAPPlugin {
98
94
  }
99
95
 
100
96
  @objc func disableBackgroundUpdates(_ call: CAPPluginCall) {
101
- disableBackgroundUpdates()
97
+ stopBackgroundUpdates()
102
98
  call.resolve()
103
99
  }
104
100
 
@@ -154,29 +150,16 @@ public class BackgroundUpdatePlugin: CAPPlugin {
154
150
 
155
151
  // MARK: - Private Methods
156
152
 
157
- /// Plain Swift call — used by `NativeUpdatePlugin.cleanup()` so it
158
- /// doesn't have to manufacture a `CAPPluginCall` (the relevant
159
- /// initializer is internal in the public Capacitor SDK).
160
- func disableBackgroundUpdatesInternal() {
153
+ /// Stop scheduled work from either a plugin call or plugin cleanup.
154
+ func stopBackgroundUpdates() {
161
155
  backgroundUpdateStatus.enabled = false
162
156
  backgroundUpdateStatus.isRunning = false
163
157
  backgroundUpdateStatus.currentTaskId = nil
164
158
 
165
- if #available(iOS 13.0, *) {
166
- BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: backgroundTaskIdentifier)
167
- }
159
+ BGTaskScheduler.shared.cancel(taskRequestWithIdentifier: backgroundTaskIdentifier)
168
160
  }
169
161
 
170
- private func disableBackgroundUpdates() {
171
- disableBackgroundUpdatesInternal()
172
- }
173
-
174
162
  private func scheduleBackgroundTask(interval: Int) {
175
- guard #available(iOS 13.0, *) else {
176
- NSLog("[native-update] BackgroundTasks framework not available on iOS < 13.0")
177
- return
178
- }
179
-
180
163
  // Cancel any prior pending request with this identifier before
181
164
  // submitting a new one. iOS documents submit() as replacing an
182
165
  // existing request of the same identifier, but a few OS versions
@@ -20,7 +20,7 @@ class LiveUpdatePlugin: @unchecked Sendable {
20
20
  // (crash-loop auto-rollback) defenses. Mirrors the Android constants
21
21
  // in LiveUpdatePlugin.kt so the two platforms stay in lockstep.
22
22
  /// This plugin's version, sent as X-Sdk-Version. Kept equal to package.json by tests/sdk-version.test.ts.
23
- static let sdkVersion = "4.4.6"
23
+ static let sdkVersion = "5.0.1"
24
24
  private static let activeBundleKey = "native_update_active_bundle"
25
25
  private static let previousBundleKey = "native_update_previous_active_bundle"
26
26
  private static let pendingBundleKey = "native_update_pending_verify_bundle"
@@ -516,6 +516,7 @@ class LiveUpdatePlugin: @unchecked Sendable {
516
516
  // SDK identity: the server offers this WebView only web bundles (docs/protocol/CLIENT-PROTOCOL.md).
517
517
  request.setValue("capacitor", forHTTPHeaderField: "X-Client-Sdk")
518
518
  request.setValue(LiveUpdatePlugin.sdkVersion, forHTTPHeaderField: "X-Sdk-Version")
519
+ request.setValue(Locale.current.identifier.replacingOccurrences(of: "_", with: "-"), forHTTPHeaderField: "Accept-Language")
519
520
  // App-identity header for API-key client restrictions (bundle id only;
520
521
  // team id is intentionally not sent by the plugin).
521
522
  if let bundleId = Bundle.main.bundleIdentifier {
@@ -73,20 +73,7 @@ public class NativeUpdatePlugin: CAPPlugin {
73
73
 
74
74
  @objc func cleanup(_ call: CAPPluginCall) {
75
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()
76
+ backgroundUpdatePlugin.stopBackgroundUpdates()
90
77
  call.resolve()
91
78
  }
92
79
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "native-update-capacitor",
3
- "version": "4.4.6",
3
+ "version": "5.0.1",
4
4
  "packageManager": "yarn@4.18.1",
5
5
  "engines": {
6
6
  "node": ">=24.16.0"
7
7
  },
8
- "description": "The Native Update Capacitor plugin under its framework name. Identical to native-update 4.4.6: signed OTA updates, in-app update and in-app review.",
8
+ "description": "The Native Update Capacitor plugin under its framework name. Identical to native-update 5.0.1: signed OTA updates, in-app update and in-app review.",
9
9
  "type": "module",
10
10
  "main": "dist/plugin.cjs",
11
11
  "module": "dist/esm/index.js",
@@ -23,17 +23,17 @@
23
23
  },
24
24
  "bin": "cli/index.js",
25
25
  "files": [
26
- "android/src/main/",
26
+ "android/src/main/**/*",
27
27
  "android/build.gradle",
28
28
  "android/variables.gradle",
29
29
  "android/gradle.properties",
30
- "android/gradle/",
30
+ "android/gradle/**/*",
31
31
  "android/settings.gradle",
32
32
  "android/proguard-rules.pro",
33
33
  "android/consumer-rules.pro",
34
34
  "android/manifest-additions.xml",
35
35
  "dist/",
36
- "ios/Plugin/",
36
+ "ios/Plugin/**/*",
37
37
  "NativeUpdate.podspec",
38
38
  "docs/CHANGELOG.md",
39
39
  "docs/MIGRATION.md",
@@ -54,6 +54,10 @@
54
54
  "url": "https://aoneahsan.com"
55
55
  },
56
56
  "license": "SEE LICENSE IN LICENSE",
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "https://github.com/aoneahsan/native-update.git"
60
+ },
57
61
  "bugs": {
58
62
  "url": "https://nativeupdate.aoneahsan.com/contact"
59
63
  },
@@ -85,11 +89,14 @@
85
89
  "prompts": "^2.4.2"
86
90
  },
87
91
  "devDependencies": {
88
- "@capacitor/app": "^8.1.2",
89
- "@capacitor/core": "^8.6.2",
90
- "@capacitor/device": "^8.0.3",
91
- "@capacitor/filesystem": "^8.1.5",
92
- "@capacitor/preferences": "^8.0.1",
92
+ "@capacitor/android": "^9.0.0",
93
+ "@capacitor/app": "^9.0.2",
94
+ "@capacitor/cli": "^9.0.0",
95
+ "@capacitor/core": "^9.0.0",
96
+ "@capacitor/device": "^9.0.2",
97
+ "@capacitor/filesystem": "^9.0.0",
98
+ "@capacitor/ios": "^9.0.0",
99
+ "@capacitor/preferences": "^9.0.2",
93
100
  "@rollup/plugin-node-resolve": "^16.0.3",
94
101
  "@rollup/plugin-terser": "^1.0.2",
95
102
  "@types/node": "^26.6.6",
@@ -104,11 +111,11 @@
104
111
  "vitest": "^5.1.0"
105
112
  },
106
113
  "peerDependencies": {
107
- "@capacitor/app": ">=8.0.0",
108
- "@capacitor/core": "^8.0.1",
109
- "@capacitor/device": ">=8.0.0",
110
- "@capacitor/filesystem": ">=8.0.0",
111
- "@capacitor/preferences": ">=8.0.0"
114
+ "@capacitor/app": "^9.0.0",
115
+ "@capacitor/core": "^9.0.0",
116
+ "@capacitor/device": "^9.0.0",
117
+ "@capacitor/filesystem": "^9.0.0",
118
+ "@capacitor/preferences": "^9.0.0"
112
119
  },
113
120
  "capacitor": {
114
121
  "ios": {