Skip to content

Commit 14eee59

Browse files
committed
Avoid asking for reviews in directly distributed app
You'd expect StoreKit to do nothing in this case, but it seems to always present the dialog...
1 parent 0776663 commit 14eee59

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

ExtendFS.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319
CLANG_WARN_UNREACHABLE_CODE = YES;
320320
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
321321
COPY_PHASE_STRIP = NO;
322-
CURRENT_PROJECT_VERSION = 12;
322+
CURRENT_PROJECT_VERSION = 13;
323323
DEAD_CODE_STRIPPING = YES;
324324
DEBUG_INFORMATION_FORMAT = dwarf;
325325
DEVELOPMENT_TEAM = YN43D87323;
@@ -387,7 +387,7 @@
387387
CLANG_WARN_UNREACHABLE_CODE = YES;
388388
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
389389
COPY_PHASE_STRIP = NO;
390-
CURRENT_PROJECT_VERSION = 12;
390+
CURRENT_PROJECT_VERSION = 13;
391391
DEAD_CODE_STRIPPING = YES;
392392
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
393393
DEVELOPMENT_TEAM = YN43D87323;

ExtendFS/ContentView.swift

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,33 @@ struct ContentView: View {
9090

9191
self.ext4ExtensionState = states[ext4ExtensionIdentifier] ?? .notDetermined
9292

93-
let timeSinceLastAskedForRating = lastAskedForRating.timeIntervalSinceNow.magnitude
94-
let secondsPerMonth = Double(60 * 60 * 24 * 7 * 30)
95-
if appearsActive && timeSinceLastAskedForRating > secondsPerMonth {
96-
lastAskedForRating = Date.now
97-
requestReview()
93+
if !isSignedForDirectDistribution() {
94+
let timeSinceLastAskedForRating = lastAskedForRating.timeIntervalSinceNow.magnitude
95+
let secondsPerMonth = Double(60 * 60 * 24 * 7 * 30)
96+
if appearsActive && timeSinceLastAskedForRating > secondsPerMonth {
97+
lastAskedForRating = Date.now
98+
requestReview()
99+
}
100+
}
101+
}
102+
103+
func isSignedForDirectDistribution() -> Bool {
104+
var code: SecCode? = nil
105+
SecCodeCopySelf(SecCSFlags(), &code)
106+
guard let code else { return true }
107+
var staticCode: SecStaticCode? = nil
108+
SecCodeCopyStaticCode(code, SecCSFlags(), &staticCode)
109+
guard let staticCode else { return true }
110+
var dict: CFDictionary?
111+
SecCodeCopySigningInformation(staticCode, SecCSFlags(rawValue: kSecCSSigningInformation), &dict)
112+
guard let info = dict as? [CFString: Any], let certificates = info[kSecCodeInfoCertificates] as? [SecCertificate] else {
113+
return true
114+
}
115+
return certificates.contains { cert in
116+
var commonName: CFString? = nil
117+
SecCertificateCopyCommonName(cert, &commonName)
118+
guard let commonName = commonName as? String else { return false }
119+
return commonName.contains("Developer ID Application")
98120
}
99121
}
100122

0 commit comments

Comments
 (0)