在处理购买时,我希望能够检测 Apple 的服务器是否已停止并弹出一个警报,说 Apple 的服务器不可用。听起来很容易,对吧?我遇到的问题是我不确定是否有办法判断 Apple 的服务器是否已停止运行,或者用户只是坐在 Apple 的“确认您的应用内购买”警报 View 上。这基本上发生在这个委托(delegate)方法中:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
检查交易数组的 transactionState,发起购买时在 SKPaymentTransactionStatePurchasing 上调用委托(delegate),并在购买完成后调用 SKPaymentTransactionStatePurchased。没有指示何时弹出此警报对话框以及用户是否确认,因此在这些情况下我无法可靠地弹出“不可用”消息。
我错过了什么,或者这是正确的?其他人如何处理这个问题?
最佳答案
如果事务失败,则调用以下方法:
- (void)failedTransaction:(SKPaymentTransaction *)transaction
{
NSLog(@"The error description is:%@",[transaction.error description]);
if (transaction.error.code != SKErrorUnknown)
{
// error!
//Your time to take over
}
}
你应该检查http://developer.apple.com/library/mac/#documentation/StoreKit/Reference/StoreKitTypes/Reference/reference.html
关于iphone - 在处理购买时检测 App Store 何时不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8920400/