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
This project is licensed under the terms of the MIT license. See the [LICENSE](LICENSE) file.
100
+
- Error Handling and Reporting: The current implementation of error handling in various parts of the codebase could be improved for better clarity and functionality. For instance: UpgradeAlert.swift: The method checkForUpdates uses a simple closure that returns an optional error. This could be enhanced by using a Result type to make the success and error handling paths clearer and more robust.
101
+
- UIAlertController+Ext.swift: The present method does not handle the scenario where there is no view controller available to present the alert. This could lead to silent failures in presenting critical update alerts.
102
+
- Refactoring and Code Simplification_ Refactoring some parts of the code could improve readability and maintainability. For example: UpgradeAlert+Variables.swift: The method for generating the request URL could be simplified or made more robust by handling potential errors more gracefully.
103
+
- NSAlert+Ext.swift: The method for presenting alerts in macOS could be refactored to reduce duplication and improve error handling.
104
+
- Testing and Coverage Improving tests to cover edge cases and error scenarios would enhance the reliability of the application. For instance:
105
+
- UpgradeAlertTests.swift: The test cases could be expanded to cover more scenarios, including error handling and user interaction outcomes.
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/UpgradeAlert+Variables.swift
+16-8
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,10 @@ import Foundation
5
5
extensionUpgradeAlert{
6
6
/**
7
7
* Computed property to generate the request URL for app information.
8
-
* It uses the bundle identifier of the current app to create the URL.
9
-
* - Description: This property constructs a URL used to fetch information about the application from the iTunes API based on the application's bundle identifier.
8
+
* - Note: It uses the bundle identifier of the current app to create the URL.
9
+
* - Description: This property constructs a URL used to fetch information
10
+
* about the application from the iTunes API based on the
11
+
* application's bundle identifier.
10
12
* - Returns: A URL pointing to the app's information on iTunes.
11
13
* - Note: This URL might need a country code for region-specific apps.
12
14
* - Fixme: ⚠️️ Consider renaming this to appInfoRequestURL for clarity.
@@ -24,7 +26,8 @@ extension UpgradeAlert {
24
26
extensionUpgradeAlert{
25
27
/**
26
28
* Typealias for a function that generates an alert message.
27
-
* - Description: Defines a function type used to generate a custom alert message based on the app's name and version.
29
+
* - Description: Defines a function type used to generate a custom alert
30
+
* message based on the app's name and version.
28
31
* - Parameters:
29
32
* - appName: The name of the app. This can be nil.
* This function simply prints the outcome of the operation.
46
-
* - Description: This default completion handler logs the outcome of the operation to the console, providing a simple way to observe the results of the update check or alert interaction.
49
+
* - Abstract: This function simply prints the outcome of the operation.
50
+
* - Description: This default completion handler logs the outcome of the
51
+
* operation to the console, providing a simple way to
52
+
* observe the results of the update check or alert
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/UpgradeAlert.swift
+16-5
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,10 @@ import UIKit
5
5
import Cocoa
6
6
#endif
7
7
/**
8
-
* - Description: The `UpgradeAlert` class is responsible for managing the update notification process within an application. It checks for new versions of the app on the App Store, compares it with the current version, and alerts the user if an update is necessary.
8
+
* - Description: The `UpgradeAlert` class manages the update notification
9
+
* process within an application. It checks for new versions of
10
+
* the app on the App Store, compares it with the current
11
+
* version, and alerts the user if an update is necessary.
9
12
* - Remark: What if a user doesn't want to update and there is no other option than to update?
10
13
* - Remark: If the app always show popup when getting focus. Then activate flight-mode. Launch the app again.
11
14
* - Remark: Title and message are optional, default values are used if nil etc
@@ -18,13 +21,21 @@ public final class UpgradeAlert {}
18
21
extensionUpgradeAlert{
19
22
/**
20
23
* Check for updates
21
-
* - Description: Initiates a check for new versions of the app available on the App Store. If a newer version is found, it prompts the user with an update alert.
24
+
* - Description: Initiates a check for new versions of the app available
25
+
* on the App Store. If a newer version is found, it prompts
26
+
* the user with an update alert.
22
27
* - Remark: shows alert with one or two btns
23
-
* - Parameter: withConfirmation You can force the update by calling, Or the user can choose if they want to update now or later by calling
24
-
* - Remark: Version of the app you want to mark for the update. For example, 1.0.0 // This is the version you want the user to force upgrade to a newer version.
28
+
* - Remark: Version of the app you want to mark for the update.
29
+
* For example, 1.0.0 // This is the version you want the user
30
+
* to force upgrade to a newer version.
25
31
* - Fixme: ⚠️️ Add onAppStoreOpenComplete -> ability to track how many update etc
26
32
* - Fixme: ⚠️️ Use Result instead etc
27
-
* - Parameter complete: A closure that is called when the update check is complete. It returns an optional AppInfo object and an optional NSError object. If an error occurs during the update check, the NSError object describes the error. If the update check is successful, the AppInfo object contains information about the app.
33
+
* - Parameter complete: A closure that is called when the update check
34
+
* is complete. It returns an optional AppInfo object
35
+
* and an optional NSError object. If an error occurs
36
+
* during the update check, the NSError object describes
37
+
* the error. If the update check is successful, the
38
+
* AppInfo object contains information about the app.
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/ext/Bundle+Ext.swift
+3-1
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,9 @@ extension Bundle {
30
30
/**
31
31
* Tests if an app is in beta
32
32
* - Abstract: determines if beta from receipt
33
-
* - Description: Determines if the application is a beta version by checking the app store receipt URL for specific substrings that identify simulator or TestFlight environments.
33
+
* - Description: Determines if the application is a beta version by
34
+
* checking the app store receipt URL for specific substrings that
35
+
* identify simulator or TestFlight environments.
34
36
* - Note: From here: https://stackoverflow.com/a/38984554/5389500
35
37
* - Note: More complex example: https://stackoverflow.com/a/33830605/5389500
36
38
* - Note: Another example: https://stackoverflow.com/a/59047187/5389500
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/ext/NSAlert+Ext.swift
+8-3
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ import Cocoa
4
4
extensionNSAlert{
5
5
/**
6
6
* Presents a warning alert to the user with customizable text, buttons, and completion handler.
7
-
* - Description: Displays a modal alert dialog on macOS with customizable titles for the buttons and a completion handler to capture the user's response.
7
+
* - Description: Displays a modal alert dialog on macOS with customizable
8
+
* titles for the buttons and a completion handler to capture
9
+
* the user's response.
8
10
* ## Examples:
9
11
* NSAlert.present(question: "Ok?", text: "Choose your answer.") { answer in
10
12
* print(answer)
@@ -15,8 +17,11 @@ extension NSAlert {
15
17
* - text: The informative text of the alert.
16
18
* - okTitle: The text for the OK button. Defaults to "OK".
17
19
* - cancelTitle: The text for the cancel button. Defaults to "Cancel".
18
-
* - view: The view to present the alert from. If nil, the alert is presented from the first window of the application.
19
-
* - complete: A closure that is called when the user dismisses the alert. The closure takes a single Boolean parameter that is true if the user clicked the OK button and false otherwise.
20
+
* - view: The view to present the alert from. If nil, the alert is
21
+
* presented from the first window of the application.
22
+
* - complete: A closure that is called when the user dismisses the alert.
23
+
* The closure takes a single Boolean parameter that is true if
24
+
* the user clicked the OK button and false otherwise.
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/ext/UIAlertController+Ext.swift
+6-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ import UIKit
4
4
extensionUIAlertController{
5
5
/**
6
6
* Present alert
7
-
* - Description: Presents the alert controller modally on the currently active view controller or the root view controller if no other controllers are presented.
7
+
* - Description: Presents the alert controller modally on the currently
8
+
* active view controller or the root view controller if no other
9
+
* controllers are presented.
8
10
* Fix: throw error if vc is not available?
9
11
*/
10
12
internalfunc present(){
@@ -17,7 +19,9 @@ extension UIAlertController {
17
19
extensionUIAlertController{
18
20
/**
19
21
* Presented or root view-controller
20
-
* - Description: Retrieves the currently presented view controller or the root view controller if no other view controller is presented.
22
+
* - Description: Retrieves the currently presented view controller or the
23
+
* root view controller if no other view controller is
24
+
* presented.
21
25
* - Note: Sometimes there is no vc: https://stackoverflow.com/a/30509569/5389500
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/helper/AppInfo.swift
+18-7
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,38 @@ import Foundation
2
2
3
3
/**
4
4
* This struct represents the basic information about an application.
5
-
* It includes the current version of the application and the URL to the application's page on the App Store.
6
-
* - Description: This struct encapsulates essential details about the application, such as its current version and the URL to its App Store page, facilitating easy access to its public listing for update and review purposes.
7
-
* - Remark: More information such as rating, release date, release notes etc. can be fetched. For more details, see: https://github.com/amebalabs/AppVersion/blob/master/AppVersion/Source/AppStoreVersion.swift
5
+
* - Abstract: It includes the current version of the application and the URL
6
+
* to the application's page on the App Store.
7
+
* - Description: This struct encapsulates essential details about the
8
+
* application, such as its current version and the URL to its App Store
9
+
* page, facilitating easy access to its public listing for update and
10
+
* review purposes.
11
+
* - Remark: More information such as rating, release date, release notes etc.
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/helper/UAConfig.swift
+4-1
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,10 @@ extension UAConfig {
55
55
/**
56
56
* Provides a default configuration for the alert.
57
57
* This can be used when no specific configuration is provided.
58
-
* - Description: Returns a default `UAConfig` instance with predefined values for alert title, message, and button titles, suitable for general use cases where a specific configuration is not necessary.
58
+
* - Description: Returns a default `UAConfig` instance with predefined
59
+
* values for alert title, message, and button titles,
Copy file name to clipboardexpand all lines: Sources/UpgradeAlert/helper/UAError.swift
+15-5
Original file line number
Diff line number
Diff line change
@@ -2,29 +2,39 @@ import Foundation
2
2
/**
3
3
* Error type. So we can track if bundle id etc faults.
4
4
* This enum is used to handle errors in a more structured way, allowing for better error handling and debugging.
5
-
* - Description: Enumerates the various errors that can occur within the UpgradeAlert system, providing specific types for different error scenarios to facilitate precise error handling.
5
+
* - Description: Enumerates the various errors that can occur within the
6
+
* UpgradeAlert system, providing specific types for different
7
+
* error scenarios to facilitate precise error handling.
6
8
*/
7
9
publicenumUAError:Error{
8
10
/**
9
11
* This error is thrown when the URL for the App Store is invalid.
10
-
* - Description: Occurs when the URL intended to direct to the App Store is malformed or not properly formatted, preventing navigation to the App Store page.
12
+
* - Description: Occurs when the URL intended to direct to the App Store
13
+
* is malformed or not properly formatted, preventing
14
+
* navigation to the App Store page.
11
15
*/
12
16
case invalidAppStoreURL
13
17
/**
14
18
* This error is thrown when a general URL is invalid.
15
-
* - Description: Occurs when a general URL that is not specifically for the App Store is malformed or not properly formatted, preventing proper URL navigation or usage.
19
+
* - Description: Occurs when a general URL that is not specifically for
20
+
* the App Store is malformed or not properly formatted,
21
+
* preventing proper URL navigation or usage.
16
22
*/
17
23
case invalideURL
18
24
/**
19
25
* This error is thrown when the response from a request is invalid.
20
26
* - Parameter description: Provides more details about the error.
21
-
* - Description: Provides a detailed explanation of what went wrong with the response, including specifics that can help in debugging the issue.
27
+
* - Description: Provides a detailed explanation of what went wrong
28
+
* with the response, including specifics that can help
29
+
* in debugging the issue.
22
30
*/
23
31
case invalidResponse(description:String)
24
32
/**
25
33
* This error is thrown when there is an issue with the bundle.
26
34
* The desc parameter provides more details about the error.
27
-
* - Description: Indicates an error related to the application's bundle, such as missing required resources or incorrect configuration settings.
35
+
* - Description: Indicates an error related to the application's bundle,
0 commit comments