You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Testing and Coverage Improving tests to cover edge cases and error scenarios would enhance the reliability of the application. For instance:
105
105
- UpgradeAlertTests.swift: The test cases could be expanded to cover more scenarios, including error handling and user interaction outcomes.
106
106
- Upgrade this to Swift 6.0 (Might be a bit tricky)
107
+
- Add a way to inject text for alert. so we can localize text from the caller etc.as we might want to use .modules with localizations etc
108
+
- Enhance Error Handling with Swift's Result Type
109
+
Issue: The current implementation of asynchronous methods uses custom closures with optional parameters for error handling. This can be improved by leveraging Swift's Result type, which provides a clearer and more structured way to handle success and failure cases.
110
+
Improvement: Refactor asynchronous methods to use Result instead of optional parameters. This will make the code more readable and maintainable.
111
+
112
+
```
113
+
public final class UpgradeAlert {
114
+
public static func checkForUpdates(completion: @escaping (Result<Void, UAError>) -> Void) {
115
+
DispatchQueue.global(qos: .background).async {
116
+
getAppInfo { result in
117
+
switch result {
118
+
case .success(let appInfo):
119
+
let needsUpdate = ComparisonResult.compareVersion(
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/UpgradeAlert.swift
+13
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,19 @@ extension UpgradeAlert {
100
100
101
101
throwNSError(domain:"no app info", code:0) // If there is no app info, throw an NSError with the description "no app info"
102
102
}
103
+
104
+
// ⚠️️ new
105
+
// The App Store metadata may be updated before the app binary is available, causing users to see an update prompt before they can download the update.
106
+
// Check the currentVersionReleaseDate from the App Store response and delay prompting users if the update is very recent.
case.orderedSame:// The current version is the same as the App Store version.
44
-
//print("same version")
45
-
return.compatible
46
-
case.orderedAscending:// The current version is older than the App Store version.
47
-
// will execute the code here
48
-
// print("ask user to update")
49
-
return.requiresUpgrade
50
-
case.orderedDescending: // app-store listing hasn't updated yet, The current version is newer than the App Store version. This is an unexpected case.
51
-
// execute if current > appStore
52
-
// print("don't expect happen...")
41
+
// let versionCompare/*: ComparisonResult*/ = current.compare(appStore, options: .numeric)
42
+
// switch versionCompare {
43
+
// case .orderedSame:// The current version is the same as the App Store version.
44
+
// //print("same version")
45
+
// return .compatible
46
+
// case .orderedAscending:// The current version is older than the App Store version.
47
+
// // will execute the code here
48
+
// // print("ask user to update")
49
+
// return .requiresUpgrade
50
+
// case .orderedDescending: // app-store listing hasn't updated yet, The current version is newer than the App Store version. This is an unexpected case.
51
+
// // execute if current > appStore
52
+
// // print("don't expect happen...")
53
+
// return .compatible
54
+
// }
55
+
if current.compare(appStore, options:.numeric)==.orderedAscending {
0 commit comments