Fix missing beta check on tvOS (#925)

Reuse the same receipt trick from iOS.

Also, fix a regression in IAPManager.fetchLevelIfNeeded() from #903,
where a guard after an await was dropped leading to reentrancy issues.
This commit is contained in:
Davide 2024-11-24 21:19:43 +01:00 committed by GitHub
parent a6f132a6e6
commit fa293656f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -270,6 +270,9 @@ private extension IAPManager {
return
}
let isBeta = await betaChecker.isBeta()
guard userLevel == .undefined else {
return
}
userLevel = isBeta ? .beta : .freemium
pp_log(.App.iap, .info, "App level: \(userLevel)")
}

View File

@ -47,8 +47,8 @@ private extension TestFlightChecker {
func verifyBetaBuild() -> Bool {
#if os(macOS) || targetEnvironment(macCatalyst)
isMacTestFlightBuild
#elseif os(iOS)
isiOSSandboxBuild
#elseif os(iOS) || os(tvOS)
isSandboxBuild
#else
false
#endif
@ -59,12 +59,17 @@ private extension TestFlightChecker {
}
}
// MARK: iOS
// MARK: iOS/tvOS
#if os(iOS)
#if os(iOS) || os(tvOS)
private extension TestFlightChecker {
var isiOSSandboxBuild: Bool {
bundle.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
var isSandboxBuild: Bool {
guard let url = bundle.appStoreReceiptURL else {
NSLog("No Bundle.main.appStoreReceiptURL")
return false
}
NSLog("Bundle.main.appStoreReceiptURL = \(url)")
return bundle.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
}
}
#endif