@@ -56,14 +56,8 @@ func getDeviceMaxBrightness() -> Float {
56
56
return 1.59
57
57
}
58
58
59
- private func getAppTransaction( ) async -> VerificationResult < AppTransaction > ? {
60
- do {
61
- let shared = try await AppTransaction . shared
62
- return shared
63
- } catch {
64
- print ( " Fetching app transaction failed " )
65
- }
66
- return nil
59
+ private func getAppTransaction( ) async throws -> VerificationResult < AppTransaction > ? {
60
+ return try await AppTransaction . shared
67
61
}
68
62
69
63
func generateReport( ) async -> String {
@@ -75,33 +69,41 @@ func generateReport() async -> String {
75
69
report += " Version: BrightIntosh v \( appVersion) \n "
76
70
#endif
77
71
report += " Model Identifier: \( getModelIdentifier ( ) ?? " N/A " ) \n "
78
- if let sharedAppTransaction = await getAppTransaction ( ) {
79
- if case . verified( let appTransaction) = sharedAppTransaction {
80
- report += " Original Purchase Date: \( appTransaction. originalPurchaseDate) \n "
81
- report += " Original App Version: \( appTransaction. originalAppVersion) \n "
82
- report += " Transaction for App Version: \( appTransaction. appVersion) \n "
83
- report += " Transaction Environment: \( appTransaction. environment. rawValue) \n "
84
- }
85
- if case . unverified( _, let verificationError) = sharedAppTransaction {
86
- report +=
87
- " Error: App Transaction: \( verificationError. errorDescription ?? " no error description " ) - \( verificationError. failureReason ?? " no failure reason " ) \n "
72
+ do {
73
+ if let sharedAppTransaction = try await getAppTransaction ( ) {
74
+ if case . verified( let appTransaction) = sharedAppTransaction {
75
+ report += " Original Purchase Date: \( appTransaction. originalPurchaseDate) \n "
76
+ report += " Original App Version: \( appTransaction. originalAppVersion) \n "
77
+ report += " Transaction for App Version: \( appTransaction. appVersion) \n "
78
+ report += " Transaction Environment: \( appTransaction. environment. rawValue) \n "
79
+ }
80
+ if case . unverified( _, let verificationError) = sharedAppTransaction {
81
+ report += " Error: App Transaction: \( verificationError. errorDescription ?? " no error description " ) - \( verificationError. failureReason ?? " no failure reason " ) \n "
82
+ }
83
+ } else {
84
+ report += " Error: No App Transaction available \n "
88
85
}
89
- } else {
90
- report += " Error: App Transaction could not be fetched \n "
86
+ } catch {
87
+ report += " Error: App Transaction could not be fetched: \( error . localizedDescription ) \n "
91
88
}
92
89
93
- let isUnrestricted = try ? await EntitlementHandler . shared. isUnrestrictedUser ( )
94
- report += " Unrestricted user: \( isUnrestricted) \n "
90
+ do {
91
+ let isUnrestricted = try await EntitlementHandler . shared. isUnrestrictedUser ( refresh: true )
92
+ report += " Unrestricted user: \( isUnrestricted) \n "
93
+ } catch {
94
+ report += " Error: EntitlementHandler threw an error: \( error. localizedDescription) \n "
95
+ }
95
96
do {
96
97
let trial = try await TrialData . getTrialData ( )
97
- report +=
98
- " Trial: \n - Start Date: \( trial. purchaseDate) \n - Current Date: \( trial. currentDate) \n - Remaining: \( trial. getRemainingDays ( ) ) \n "
98
+ report += " Trial: \n - Start Date: \( trial. purchaseDate) \n - Current Date: \( trial. currentDate) \n - Remaining: \( trial. getRemainingDays ( ) ) \n "
99
99
} catch {
100
- report += " Error: Trial Data could not be fetched \n "
100
+ report += " Error: Trial Data could not be fetched \( error . localizedDescription ) \n "
101
101
}
102
- report += " Screens: \( NSScreen . screens. map { $0. localizedName} . joined ( separator: " , " ) ) \n "
102
+
103
+ let screens = NSScreen . screens. map { $0. localizedName}
104
+ report += " Screens: \( screens. joined ( separator: " , " ) ) \n "
103
105
for screen in NSScreen . screens {
104
- report += " - Screen \( NSScreen . screens . map { $0 . localizedName} ) : \( screen. frame. width) x \( screen. frame. height) px \n "
106
+ report += " - Screen \( screen . localizedName) : \( screen. frame. width) x \( screen. frame. height) px \n "
105
107
}
106
108
return report
107
109
}
0 commit comments