了解用户在应用内购买时何时按下了取消按钮 [英] Knowing when user has pressed cancel buttons during In-App purchase
问题描述
我正在为应用内购买编写代码,并使用带有活动指示符的正在处理...视图,以便在启动购买时阻止立即购买按钮。但是,如果用户点击取消按钮,您怎么知道这些警报视图来自AppStore.app?
I am writing code for in-app purchases and using a "Processing..." view with an activity indicator to block the "Buy Now" button once a purchase is initiated. However, how can you tell when the user hits a "Cancel" button since those alert views are coming from the AppStore.app?
是否有按下取消按钮时调用的委托方法?或者您的观点再次成为 firstResponder
?我在这里缺少什么?
Is there a delegate method that gets called when those cancel buttons are pressed? Or is it a matter of your view becoming firstResponder
again? What am I missing here?
如果您认为这不可行,请查看我是T-Pain应用程序......他们做了些什么非常相似,并在按下取消按钮后立即关闭他们的视图。
If you don't think this is possible, have a look at the "I Am T-Pain" app... they do something very similar and dismiss their view immediately after the cancel button is pressed.
替代文字http://i37.tinypic.com/1t4ead.png
推荐答案
假设一切都设置正确你应该有一个实现 SKPaymentTransactionObserver 的对象,它将收到交易成功/失败/取消的回调。
Assuming everything is setup correctly you should have an object implementing SKPaymentTransactionObserver which will receive callbacks for transaction success/failure/cancel.
在我的例子中它是此次调用中提到的 purchaseManager 对象
In my example it's the purchaseManager object mentioned in this call
[[SKPaymentQueue defaultQueue] addTransactionObserver:purchaseManager];
当用户取消付款时,您应该收到一个交易状态为已取消的回调:
When the user cancels a payment you should receive a callback with a transaction state of cancelled:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
// THIS IS THE STATE YOU SHOULD SEE
[self failedTransaction:transaction];
break;
...
}
您可以使用此回调来关闭您的观点等......
You can use this callback to dismiss your view etc...
这篇关于了解用户在应用内购买时何时按下了取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!