Given an SKPaymentTransaction
is there a way to get the SKProduct
?
I'm trying to implement a generic SKPaymentTransactionObserver
that will allow my app to be notified of all in-app purchases that occur. I have implemented the SKPaymentTransactionObserver
interface, and I am getting the paymentQueue: updatedTransactions:
callback firing correctly. In my callback I have access to the SKPaymentTransaction
object, and from there I can get the SKPayment
object. From the payment I cannot find a way to get the SKProduct
though.
This is frustrating since the SKPayment
must have been created using the SKProduct
, but the interface only allows the user to get the productIdentifier
. To create an SKPayment
Really, I want to get access to the cost, quantity, and local currency that was spent, and these are properties of the SKProduct
.
The only way I can see to do this is to swizzle [SKPayment paymentWithProduct:]` and intercept payment creation, which is an awful prospect.
An object containing the subscription period duration information. enum SKProduct.PeriodUnit. Values representing the duration of an interval, from a day up to a year.
StoreKit provides a simple and secure way to purchase digital goods or services in your apps across all Apple platforms, so people can start playing, gaming, reading, and more, right away.
I don't think it is possible right now to get that information from the the SKPaymentTransaction or its SKPayment object.
You could query this information though by setting up a SKProductRequest with one or more product identifiers. The response is handled by productsRequest:didReceiveResponse.
Apple's documentation has a pretty good example of how to do it here.
Given an SKPaymentTransaction is there a way to get the SKProduct?
You could get the productIdentifier from the transaction object from which you can get the product info if you have an array of SKProducts by looking up the array for productIdentifier,
transaction.payment.productIdentifier
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With