|
@@ -88,6 +88,14 @@ extension SKPaymentTransactionState: CustomDebugStringConvertible {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+struct EntitlementRevocation {
|
|
|
|
+ let callback: ([String]) -> Void
|
|
|
|
+
|
|
|
|
+ init(callback: @escaping ([String]) -> Void) {
|
|
|
|
+ self.callback = callback
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
|
|
class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
|
|
|
|
|
|
private let paymentsController: PaymentsController
|
|
private let paymentsController: PaymentsController
|
|
@@ -97,7 +105,9 @@ class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
|
|
private let completeTransactionsController: CompleteTransactionsController
|
|
private let completeTransactionsController: CompleteTransactionsController
|
|
|
|
|
|
unowned let paymentQueue: PaymentQueue
|
|
unowned let paymentQueue: PaymentQueue
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private var entitlementRevocation: EntitlementRevocation?
|
|
|
|
+
|
|
deinit {
|
|
deinit {
|
|
paymentQueue.remove(self)
|
|
paymentQueue.remove(self)
|
|
}
|
|
}
|
|
@@ -145,6 +155,10 @@ class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
|
|
paymentsController.append(payment)
|
|
paymentsController.append(payment)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func onEntitlementRevocation(_ revocation: EntitlementRevocation) {
|
|
|
|
+ self.entitlementRevocation = revocation
|
|
|
|
+ }
|
|
|
|
+
|
|
func restorePurchases(_ restorePurchases: RestorePurchases) {
|
|
func restorePurchases(_ restorePurchases: RestorePurchases) {
|
|
assertCompleteTransactionsWasCalled()
|
|
assertCompleteTransactionsWasCalled()
|
|
|
|
|
|
@@ -233,6 +247,10 @@ class PaymentQueueController: NSObject, SKPaymentTransactionObserver {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func paymentQueue(_ queue: SKPaymentQueue, didRevokeEntitlementsForProductIdentifiers productIdentifiers: [String]) {
|
|
|
|
+ self.entitlementRevocation?.callback(productIdentifiers)
|
|
|
|
+ }
|
|
|
|
+
|
|
func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {
|
|
func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {
|
|
|
|
|
|
}
|
|
}
|