Skip to content

Expose SKProduct in PurchaseDetails type returned by PurchaseResult

Compare
Choose a tag to compare
@bizz84 bizz84 released this 12 May 08:32
· 443 commits to master since this release

This is a minor release which includes a fix for #185 (addressed in #206). Summary:

When a purchase succeeds, it is desirable to get access to the purchased SKProduct in the completion block, so that it's possible to query the price and other properties.

With this change, this is now possible:

SwiftyStoreKit.purchaseProduct("productId", atomically: true) { result in
    if case .success(let purchase) = result {
        // Deliver content from server, then:
        if purchase.needsFinishTransaction {
            SwiftyStoreKit.finishTransaction(purchase.transaction)
        }
        print("Purchased product with price: \(purchase.product.price)")
    }
}