Split Apple TV purchase (#467)

Full version features were listed when purchasing the Apple TV feature,
and this was very misleading.
This commit is contained in:
Davide De Rosa 2024-01-11 17:52:05 +01:00 committed by GitHub
parent 917e712510
commit 3fb521a584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 31 deletions

View File

@ -60,7 +60,7 @@ struct AddProviderView: View {
themeCloseItem(isPresented: bindings.$isPresented)
}.sheet(isPresented: $viewModel.isPaywallPresented) {
NavigationView {
PaywallView(isPresented: $viewModel.isPaywallPresented)
PaywallView(isPresented: $viewModel.isPaywallPresented, feature: .allProviders)
}.themeGlobal()
}.navigationTitle(L10n.AddProfile.Shared.title)
.themeSecondaryView()

View File

@ -54,9 +54,11 @@ extension PaywallView {
var body: some View {
List {
if feature != .appleTV {
skFullVersion.map {
fullFeaturesSection(withHeader: $0.localizedTitle)
}
}
purchaseSection
.disabled(purchaseState != nil)
restoreSection

View File

@ -31,9 +31,9 @@ struct PaywallView: View {
@Binding private var isPresented: Bool
private let feature: LocalProduct?
private let feature: LocalProduct
init<MT>(modalType: Binding<MT?>, feature: LocalProduct? = nil) {
init<MT>(modalType: Binding<MT?>, feature: LocalProduct) {
let isPresented = Binding<Bool> {
modalType.wrappedValue != nil
} set: {
@ -44,7 +44,7 @@ struct PaywallView: View {
self.init(isPresented: isPresented, feature: feature)
}
init(isPresented: Binding<Bool>, feature: LocalProduct? = nil) {
init(isPresented: Binding<Bool>, feature: LocalProduct) {
productManager = .shared
_isPresented = isPresented
self.feature = feature

View File

@ -301,7 +301,15 @@ extension ProductManager {
// purchased platform -> may only purchase other platform
public func purchasableProducts(withFeature feature: LocalProduct?) -> [LocalProduct] {
var products: [LocalProduct] = {
// separate purchase
guard feature != .appleTV else {
if hasPurchased(.appleTV) {
return []
}
return [.appleTV]
}
if hasPurchased(.fullVersion) {
return []
}
@ -322,11 +330,6 @@ extension ProductManager {
}
return [.fullVersion, .fullVersion_iOS]
#endif
}()
if feature == .appleTV && !hasPurchased(.appleTV) {
products.append(.appleTV)
}
return products
}
}

View File

@ -223,7 +223,7 @@ final class ProductManagerTests: XCTestCase {
reader.setReceipt(withBuild: 1500, products: [])
let sut = ProductManager(inApp: inApp, receiptReader: reader, buildProducts: noBuildProducts)
XCTAssertTrue(sut.purchasableProducts(withFeature: .appleTV).contains(.appleTV))
XCTAssertEqual(sut.purchasableProducts(withFeature: .appleTV), [.appleTV])
}
func test_givenAppleTV_whenDidPurchase_thenCannotPurchase() {
@ -231,6 +231,6 @@ final class ProductManagerTests: XCTestCase {
reader.setReceipt(withBuild: 1500, products: [.appleTV])
let sut = ProductManager(inApp: inApp, receiptReader: reader, buildProducts: noBuildProducts)
XCTAssertFalse(sut.purchasableProducts(withFeature: .appleTV).contains(.appleTV))
XCTAssertEqual(sut.purchasableProducts(withFeature: .appleTV), [])
}
}