@capawesome/capacitor-live-update 6.9.1 → 6.9.2
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/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdate.java +4 -2
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java +1 -1
- package/ios/Plugin/LiveUpdate.swift +2 -1
- package/ios/Plugin/LiveUpdateHttpClient.swift +6 -1
- package/ios/Plugin/LiveUpdatePlugin.swift +1 -1
- package/package.json +1 -1
|
@@ -7,9 +7,11 @@ import android.content.pm.PackageManager;
|
|
|
7
7
|
import android.content.res.AssetManager;
|
|
8
8
|
import android.os.Build;
|
|
9
9
|
import android.os.Handler;
|
|
10
|
+
import android.os.Looper;
|
|
10
11
|
import android.util.Base64;
|
|
11
12
|
import androidx.annotation.NonNull;
|
|
12
13
|
import androidx.annotation.Nullable;
|
|
14
|
+
import androidx.core.content.pm.PackageInfoCompat;
|
|
13
15
|
import com.getcapacitor.Bridge;
|
|
14
16
|
import com.getcapacitor.Logger;
|
|
15
17
|
import com.getcapacitor.plugin.WebView;
|
|
@@ -104,7 +106,7 @@ public class LiveUpdate {
|
|
|
104
106
|
|
|
105
107
|
private final String bundlesDirectory = "_capacitor_live_update_bundles"; // DO NOT CHANGE!
|
|
106
108
|
private final String downloadsDirectory = "capawesome_capacitor_live_update_downloads";
|
|
107
|
-
private final Handler rollbackHandler = new Handler();
|
|
109
|
+
private final Handler rollbackHandler = new Handler(Looper.getMainLooper());
|
|
108
110
|
private final String manifestFileName = "capawesome-live-update-manifest.json"; // DO NOT CHANGE!
|
|
109
111
|
|
|
110
112
|
private boolean initialPageLoaded = false;
|
|
@@ -1220,7 +1222,7 @@ public class LiveUpdate {
|
|
|
1220
1222
|
}
|
|
1221
1223
|
|
|
1222
1224
|
private int getVersionCodeAsInt() throws PackageManager.NameNotFoundException {
|
|
1223
|
-
return getPackageInfo()
|
|
1225
|
+
return (int) PackageInfoCompat.getLongVersionCode(getPackageInfo());
|
|
1224
1226
|
}
|
|
1225
1227
|
|
|
1226
1228
|
private String getVersionCodeAsString() throws PackageManager.NameNotFoundException {
|
package/android/src/main/java/io/capawesome/capacitorjs/plugins/liveupdate/LiveUpdatePlugin.java
CHANGED
|
@@ -39,7 +39,7 @@ import io.capawesome.capacitorjs.plugins.liveupdate.interfaces.Result;
|
|
|
39
39
|
public class LiveUpdatePlugin extends Plugin {
|
|
40
40
|
|
|
41
41
|
public static final String TAG = "LiveUpdate";
|
|
42
|
-
public static final String VERSION = "6.9.
|
|
42
|
+
public static final String VERSION = "6.9.2";
|
|
43
43
|
public static final String SHARED_PREFERENCES_NAME = "CapawesomeLiveUpdate"; // DO NOT CHANGE
|
|
44
44
|
public static final String ERROR_APP_ID_MISSING = "appId must be configured.";
|
|
45
45
|
public static final String ERROR_BUNDLE_EXISTS = "bundle already exists.";
|
|
@@ -497,7 +497,8 @@ import CommonCrypto
|
|
|
497
497
|
|
|
498
498
|
private func downloadAndVerifyFile(url: String, file: URL, checksum: String?, signature: String?, callback: ((Progress) -> Void)?) async throws {
|
|
499
499
|
let destination: DownloadRequest.Destination = { _, _ in
|
|
500
|
-
|
|
500
|
+
// `removePreviousFile` ensures that a leftover file from a failed attempt does not fail the download
|
|
501
|
+
return (file, [.createIntermediateDirectories, .removePreviousFile])
|
|
501
502
|
}
|
|
502
503
|
let urlComponents = URLComponents(string: url)!
|
|
503
504
|
let result = try await httpClient.download(url: urlComponents.asURL(), destination: destination, callback: callback)
|
|
@@ -27,13 +27,16 @@ public class LiveUpdateHttpClient: NSObject {
|
|
|
27
27
|
|
|
28
28
|
public func download(url: URL, destination: @escaping DownloadRequest.Destination, callback: ((Progress) -> Void)?) async throws -> AFDownloadResponse<Data> {
|
|
29
29
|
var request = URLRequest(url: url)
|
|
30
|
+
// Ignore the URL cache so that a cached response is never replayed for a deterministic request URL
|
|
31
|
+
request.cachePolicy = .reloadIgnoringLocalCacheData
|
|
30
32
|
request.httpMethod = HTTPMethod.get.rawValue
|
|
31
33
|
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
32
34
|
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
33
35
|
request.setValue(deviceId, forHTTPHeaderField: "X-Device-Id")
|
|
34
36
|
}
|
|
35
37
|
return try await withCheckedThrowingContinuation { continuation in
|
|
36
|
-
|
|
38
|
+
// `validate()` treats non-2xx responses as errors so that an error body is never saved as a bundle file
|
|
39
|
+
AF.download(request, to: destination).validate().downloadProgress { progress in
|
|
37
40
|
if let callback = callback {
|
|
38
41
|
callback(progress)
|
|
39
42
|
}
|
|
@@ -45,6 +48,8 @@ public class LiveUpdateHttpClient: NSObject {
|
|
|
45
48
|
|
|
46
49
|
public func request<T: Decodable>(url: URL, type: T.Type) async throws -> AFDataResponse<T> {
|
|
47
50
|
var request = URLRequest(url: url)
|
|
51
|
+
// Ignore the URL cache so that a cached response is never replayed for a deterministic request URL
|
|
52
|
+
request.cachePolicy = .reloadIgnoringLocalCacheData
|
|
48
53
|
request.httpMethod = HTTPMethod.get.rawValue
|
|
49
54
|
request.timeoutInterval = Double(config.httpTimeout) / 1000.0
|
|
50
55
|
if let deviceId = deviceId, !deviceId.isEmpty {
|
|
@@ -8,7 +8,7 @@ import Capacitor
|
|
|
8
8
|
@objc(LiveUpdatePlugin)
|
|
9
9
|
public class LiveUpdatePlugin: CAPPlugin, CAPBridgedPlugin {
|
|
10
10
|
public static let tag = "LiveUpdate"
|
|
11
|
-
public static let version = "6.9.
|
|
11
|
+
public static let version = "6.9.2"
|
|
12
12
|
public static let userDefaultsPrefix = "CapawesomeLiveUpdate" // DO NOT CHANGE
|
|
13
13
|
|
|
14
14
|
public let identifier = "LiveUpdatePlugin"
|