Extend beta conditions
Full version in beta and locked features are not exclusive. Never consider macOS in beta (may accidentally unlock features).
This commit is contained in:
parent
1180590f40
commit
22a80014ba
|
@ -350,6 +350,8 @@ public class AppConstants {
|
|||
}
|
||||
|
||||
struct InApp {
|
||||
static let locksBetaFeatures = true
|
||||
|
||||
#if os(iOS)
|
||||
static var isBetaFullVersion: Bool {
|
||||
return ProcessInfo.processInfo.environment["FULL_VERSION"] != nil
|
||||
|
|
|
@ -40,14 +40,18 @@ public enum ProductError: Error {
|
|||
|
||||
public class ProductManager: NSObject {
|
||||
public struct Configuration {
|
||||
public let locksBetaFeatures: Bool
|
||||
|
||||
public let isBetaFullVersion: Bool
|
||||
|
||||
public let lastFullVersionBuild: Int
|
||||
|
||||
public init(
|
||||
locksBetaFeatures: Bool,
|
||||
isBetaFullVersion: Bool,
|
||||
lastFullVersionBuild: Int
|
||||
) {
|
||||
self.locksBetaFeatures = locksBetaFeatures
|
||||
self.isBetaFullVersion = isBetaFullVersion
|
||||
self.lastFullVersionBuild = lastFullVersionBuild
|
||||
}
|
||||
|
@ -92,11 +96,15 @@ public class ProductManager: NSObject {
|
|||
}
|
||||
|
||||
public var isBeta: Bool {
|
||||
#if os(iOS)
|
||||
#if targetEnvironment(simulator)
|
||||
return true
|
||||
#else
|
||||
return Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
|
||||
#endif
|
||||
#else
|
||||
return false
|
||||
#endif
|
||||
}
|
||||
|
||||
public func listProducts(completionHandler: (([SKProduct]?, Error?) -> Void)?) {
|
||||
|
@ -157,7 +165,7 @@ public class ProductManager: NSObject {
|
|||
return true
|
||||
}
|
||||
#else
|
||||
if cfg.isBetaFullVersion || purchasedFeatures.contains(.fullVersion_macOS) {
|
||||
if (isBeta && cfg.isBetaFullVersion) || purchasedFeatures.contains(.fullVersion_macOS) {
|
||||
return true
|
||||
}
|
||||
#endif
|
||||
|
@ -182,7 +190,10 @@ public class ProductManager: NSObject {
|
|||
|
||||
public func verifyEligible(forFeature feature: Product) throws {
|
||||
if isBeta {
|
||||
guard cfg.isBetaFullVersion else {
|
||||
if cfg.isBetaFullVersion {
|
||||
return
|
||||
}
|
||||
guard !cfg.locksBetaFeatures else {
|
||||
throw ProductError.beta
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +204,10 @@ public class ProductManager: NSObject {
|
|||
|
||||
public func verifyEligible(forProvider metadata: Infrastructure.Metadata) throws {
|
||||
if isBeta {
|
||||
guard cfg.isBetaFullVersion else {
|
||||
if cfg.isBetaFullVersion {
|
||||
return
|
||||
}
|
||||
guard !cfg.locksBetaFeatures else {
|
||||
throw ProductError.beta
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +218,10 @@ public class ProductManager: NSObject {
|
|||
|
||||
public func verifyEligibleForTrustedNetworks() throws {
|
||||
if isBeta {
|
||||
guard cfg.isBetaFullVersion else {
|
||||
if cfg.isBetaFullVersion {
|
||||
return
|
||||
}
|
||||
guard !cfg.locksBetaFeatures else {
|
||||
throw ProductError.beta
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +321,7 @@ extension ProductManager: SKRequestDelegate {
|
|||
extension ProductManager {
|
||||
public static let shared = ProductManager(
|
||||
Configuration(
|
||||
locksBetaFeatures: AppConstants.InApp.locksBetaFeatures,
|
||||
isBetaFullVersion: AppConstants.InApp.isBetaFullVersion,
|
||||
lastFullVersionBuild: AppConstants.InApp.lastFullVersionBuild
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue