I'm unable to get the SwiftyStoreKit.completeTransactions block to trigger when I make an atomic purchase. So within my view model, I have a wrapper function to purchase an auto-renewable subscription as you can see below in my function.
static func purchase(_ product: SKProduct) -> Promise<Void> {
let loftyLoadingViewContentModel = LoftyLoadingViewContentModel(title: "Purchasing".uppercased(), message: "We’re currently processing your\nrequest, for your subscription.")
UIApplication.topViewController()?.showLoadingView(.popOverScreen, loftyLoadingViewContentModel)
return Promise { seal in
SwiftyStoreKit.purchaseProduct(product) { purchaseResult in
switch purchaseResult {
case .success(let product):
if product.needsFinishTransaction {
SwiftyStoreKit.finishTransaction(product.transaction)
}
seal.fulfill()
log.info("Purchase Success: \(product.productId)")
case .error(let error):
UIApplication.topViewController()?.removeLoadingView()
seal.reject(error)
}
}
}
}
But this doesn't trigger the block within my appdelegate.
What did you expect to happen
I expected the complete transactions block to execute.
SwiftyStoreKit.completeTransactions(atomically: true) { purchases in
for purchase in purchases {
switch purchase.transaction.transactionState {
case .purchased, .restored:
if purchase.needsFinishTransaction {
// TODO: Set flags here that the user has now purchased the product
SwiftyStoreKit.finishTransaction(purchase.transaction)
}
// Unlock content
case .failed, .purchasing, .deferred:
break // do nothing
}
}
}
Platform
In app purchase type
Environment
Version
0.14.1
Issue summary
I'm unable to get the
SwiftyStoreKit.completeTransactions
block to trigger when I make an atomic purchase. So within my view model, I have a wrapper function to purchase an auto-renewable subscription as you can see below in my function.But this doesn't trigger the block within my appdelegate.
What did you expect to happen
I expected the complete transactions block to execute.
What happened instead
Nothing happened.