Only drop features if refunded
Retain existing providers and trusted networks in beta.
This commit is contained in:
parent
b064d76a56
commit
5b4d406ccf
|
@ -41,12 +41,13 @@ extension ProductManager {
|
|||
public func reviewPurchases() {
|
||||
let service = TransientStore.shared.service
|
||||
reloadReceipt(andNotify: false)
|
||||
let isFullVersion = (try? isEligible(forFeature: .fullVersion)) ?? false
|
||||
var anyRefund = false
|
||||
|
||||
// review features and potentially revert them if they were used (Siri is handled in AppDelegate)
|
||||
|
||||
log.debug("Checking 'Trusted networks'")
|
||||
if !((try? isEligible(forFeature: .trustedNetworks)) ?? false) {
|
||||
if isCancelledPurchase(.fullVersion) || (!isFullVersion && isCancelledPurchase(.trustedNetworks)) {
|
||||
|
||||
// reset trusted networks for ALL profiles (must load first)
|
||||
for key in service.allProfileKeys() {
|
||||
|
@ -76,7 +77,7 @@ extension ProductManager {
|
|||
guard let metadata = InfrastructureFactory.shared.metadata(forName: name) else {
|
||||
continue
|
||||
}
|
||||
if !((try? isEligible(forProvider: metadata)) ?? false) {
|
||||
if isCancelledPurchase(.fullVersion) || (!isFullVersion && isCancelledPurchase(metadata.product)) {
|
||||
service.removeProfile(ProfileKey(name))
|
||||
log.debug("\tRefunded provider: \(name)")
|
||||
anyRefund = true
|
||||
|
|
|
@ -65,6 +65,8 @@ public class ProductManager: NSObject {
|
|||
|
||||
private var purchaseDates: [Product: Date]
|
||||
|
||||
private var cancelledPurchases: Set<Product>
|
||||
|
||||
private var refreshRequest: SKReceiptRefreshRequest?
|
||||
|
||||
private var restoreCompletionHandler: ((Error?) -> Void)?
|
||||
|
@ -75,6 +77,7 @@ public class ProductManager: NSObject {
|
|||
purchasedAppBuild = nil
|
||||
purchasedFeatures = []
|
||||
purchaseDates = [:]
|
||||
cancelledPurchases = []
|
||||
|
||||
super.init()
|
||||
|
||||
|
@ -185,6 +188,10 @@ public class ProductManager: NSObject {
|
|||
#endif
|
||||
}
|
||||
|
||||
public func isCancelledPurchase(_ product: Product) -> Bool {
|
||||
return cancelledPurchases.contains(product)
|
||||
}
|
||||
|
||||
public func purchaseDate(forProduct product: Product) -> Date? {
|
||||
return purchaseDates[product]
|
||||
}
|
||||
|
@ -203,6 +210,7 @@ public class ProductManager: NSObject {
|
|||
purchasedAppBuild = buildNumber
|
||||
}
|
||||
purchasedFeatures.removeAll()
|
||||
cancelledPurchases.removeAll()
|
||||
|
||||
if let buildNumber = purchasedAppBuild {
|
||||
log.debug("Original purchased build: \(buildNumber)")
|
||||
|
@ -222,6 +230,7 @@ public class ProductManager: NSObject {
|
|||
}
|
||||
if let cancellationDate = $0.cancellationDate {
|
||||
log.debug("\t\(pid) [cancelled on: \(cancellationDate)]")
|
||||
cancelledPurchases.insert(product)
|
||||
return
|
||||
}
|
||||
if let purchaseDate = $0.originalPurchaseDate {
|
||||
|
|
Loading…
Reference in New Issue