From 4ebcfc207bb63517cb070083d8598793899477e9 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Feb 2021 16:30:56 +0100 Subject: [PATCH 1/5] Consider old purchases as full iOS version --- Passepartout/Core/Sources/Model/ProductManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index c166efa5..73cdeb68 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -250,7 +250,7 @@ public class ProductManager: NSObject { // treat former purchases as full versions if buildNumber <= cfg.lastFullVersionBuild { - purchasedFeatures.insert(.fullVersion) + purchasedFeatures.insert(.fullVersion_iOS) } } if let iapReceipts = receipt.inAppPurchaseReceipts { From 7abc704c24a83d3ead9281f6ef9757d6c5c8df15 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Feb 2021 16:32:59 +0100 Subject: [PATCH 2/5] Omit Siri mention in macOS purchase --- .../App/macOS/Scenes/Purchase/PurchaseViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift index 0550c385..33580def 100644 --- a/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift +++ b/Passepartout/App/macOS/Scenes/Purchase/PurchaseViewController.swift @@ -84,7 +84,7 @@ class PurchaseViewController: NSViewController { rows.append(.feature) } - let platformBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.fullVersion, .fullVersion_iOS, .fullVersion_macOS]).map { + let platformBulletsList: [String] = ProductManager.shared.featureProducts(excluding: [.siriShortcuts, .fullVersion, .fullVersion_iOS, .fullVersion_macOS]).map { return $0.localizedTitle }.sortedCaseInsensitive() let platformBullets = platformBulletsList.joined(separator: "\n") From 3a5bbf4742b7deeca26dd16052ec7ccbc7acc3b6 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Feb 2021 16:45:24 +0100 Subject: [PATCH 3/5] Prompt for trusted networks purchase Was purchasing full macOS version instead. --- .../Service/Customization/TrustedNetworksViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Passepartout/App/macOS/Scenes/Service/Customization/TrustedNetworksViewController.swift b/Passepartout/App/macOS/Scenes/Service/Customization/TrustedNetworksViewController.swift index bce8c83e..cf5faf08 100644 --- a/Passepartout/App/macOS/Scenes/Service/Customization/TrustedNetworksViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/Customization/TrustedNetworksViewController.swift @@ -111,7 +111,7 @@ class TrustedNetworksViewController: NSViewController, ProfileCustomization { try ProductManager.shared.verifyEligibleForTrustedNetworks() } catch { checkTrustEthernet.state = .off - presentPurchaseScreen(forProduct: .fullVersion_macOS) + presentPurchaseScreen(forProduct: .trustedNetworks) return } trustedNetworks.includesEthernet = (checkTrustEthernet.state == .on) @@ -134,7 +134,7 @@ class TrustedNetworksViewController: NSViewController, ProfileCustomization { do { try ProductManager.shared.verifyEligibleForTrustedNetworks() } catch { - presentPurchaseScreen(forProduct: .fullVersion_macOS) + presentPurchaseScreen(forProduct: .trustedNetworks) return false } } From 1180590f4061c491f1f38e9ab38a92f199b4bad5 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Feb 2021 16:50:46 +0100 Subject: [PATCH 4/5] Fix conditions for trusted networks and feedback Wrong on macOS. --- Passepartout/Core/Sources/Model/ProductManager.swift | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index 73cdeb68..7c794b9d 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -173,19 +173,11 @@ public class ProductManager: NSObject { } private func isEligibleForTrustedNetworks() -> Bool { - #if os(iOS) return isFullVersion() || purchasedFeatures.contains(.trustedNetworks) - #else - return isFullVersion() - #endif } public func isEligibleForFeedback() -> Bool { - #if os(iOS) return isBeta || !purchasedFeatures.isEmpty - #else - return isFullVersion() - #endif } public func verifyEligible(forFeature feature: Product) throws { From 22a80014ba638cb47fc3654d4c6d84d1dd1b01e4 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 5 Feb 2021 17:10:19 +0100 Subject: [PATCH 5/5] Extend beta conditions Full version in beta and locked features are not exclusive. Never consider macOS in beta (may accidentally unlock features). --- Passepartout/Core/Sources/AppConstants.swift | 2 ++ .../Core/Sources/Model/ProductManager.swift | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Passepartout/Core/Sources/AppConstants.swift b/Passepartout/Core/Sources/AppConstants.swift index 75c87078..bf305d35 100644 --- a/Passepartout/Core/Sources/AppConstants.swift +++ b/Passepartout/Core/Sources/AppConstants.swift @@ -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 diff --git a/Passepartout/Core/Sources/Model/ProductManager.swift b/Passepartout/Core/Sources/Model/ProductManager.swift index 7c794b9d..29a5f4ac 100644 --- a/Passepartout/Core/Sources/Model/ProductManager.swift +++ b/Passepartout/Core/Sources/Model/ProductManager.swift @@ -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 )