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:
parent
917e712510
commit
3fb521a584
|
@ -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()
|
||||
|
|
|
@ -54,8 +54,10 @@ extension PaywallView {
|
|||
|
||||
var body: some View {
|
||||
List {
|
||||
skFullVersion.map {
|
||||
fullFeaturesSection(withHeader: $0.localizedTitle)
|
||||
if feature != .appleTV {
|
||||
skFullVersion.map {
|
||||
fullFeaturesSection(withHeader: $0.localizedTitle)
|
||||
}
|
||||
}
|
||||
purchaseSection
|
||||
.disabled(purchaseState != nil)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -301,32 +301,35 @@ extension ProductManager {
|
|||
// purchased platform -> may only purchase other platform
|
||||
|
||||
public func purchasableProducts(withFeature feature: LocalProduct?) -> [LocalProduct] {
|
||||
var products: [LocalProduct] = {
|
||||
if hasPurchased(.fullVersion) {
|
||||
|
||||
// separate purchase
|
||||
guard feature != .appleTV else {
|
||||
if hasPurchased(.appleTV) {
|
||||
return []
|
||||
}
|
||||
#if targetEnvironment(macCatalyst)
|
||||
if hasPurchased(.fullVersion_macOS) {
|
||||
return []
|
||||
}
|
||||
if hasPurchased(.fullVersion_iOS) {
|
||||
return [.fullVersion_macOS]
|
||||
}
|
||||
return [.fullVersion, .fullVersion_macOS]
|
||||
#else
|
||||
if hasPurchased(.fullVersion_iOS) {
|
||||
return []
|
||||
}
|
||||
if hasPurchased(.fullVersion_macOS) {
|
||||
return [.fullVersion_iOS]
|
||||
}
|
||||
return [.fullVersion, .fullVersion_iOS]
|
||||
#endif
|
||||
}()
|
||||
if feature == .appleTV && !hasPurchased(.appleTV) {
|
||||
products.append(.appleTV)
|
||||
return [.appleTV]
|
||||
}
|
||||
return products
|
||||
|
||||
if hasPurchased(.fullVersion) {
|
||||
return []
|
||||
}
|
||||
#if targetEnvironment(macCatalyst)
|
||||
if hasPurchased(.fullVersion_macOS) {
|
||||
return []
|
||||
}
|
||||
if hasPurchased(.fullVersion_iOS) {
|
||||
return [.fullVersion_macOS]
|
||||
}
|
||||
return [.fullVersion, .fullVersion_macOS]
|
||||
#else
|
||||
if hasPurchased(.fullVersion_iOS) {
|
||||
return []
|
||||
}
|
||||
if hasPurchased(.fullVersion_macOS) {
|
||||
return [.fullVersion_iOS]
|
||||
}
|
||||
return [.fullVersion, .fullVersion_iOS]
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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), [])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue