I have implemented In App purchase in my application. While testing (with SandBox environment), when I tap on any locked feature, I get alert message from iTunes that “Do you want to buy xxx feature at $xxx ?”, with Cancel / Buy buttons.
I want to know that can I access these Cancel / Buy buttons, because I want to implement something based on which button user taps. OR. is there any way achieve like do something if user taps Cancel button and do something else if user taps Buy button.
To react to the user’s tap, you need to implement the following method
Within the method, you need to inspect the state of each transaction and act as required. Therefore, you check the transactionState property of each transaction: it can be
SKPaymentTransactionStatePurchased, SKPaymentTransactionStateFailed, SKPaymentTransactionStateRestoredorSKPaymentTransactionStatePurchasing. Ignore the latter which simply means that the transaction is not yet finished. ForSKPaymentTransactionStatePurchasedandSKPaymentTransactionStateRestoredyou need to provide the user with the feature/content just bought. ForSKPaymentTransactionStateFailedyou may show an error message.In this case be careful: if the error code isSKErrorPaymentCancelled, then this is not technically an error. The user voluntarily decided to cancel and not to buy. Apple recommends that you treat this situation not as an error.