我正在尝试将应用内购买添加到我的应用中。 我的代码与此处相同 - https://github.com/ivanacostarubio/swift-in-app-purchase-example/blob/master/In%20App%20Purchase%20Example/ViewController.swift
问题出在这里,SKPaymentTransaction始终失败 -
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]!) {
for transaction:AnyObject in transactions {
if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
switch trans.transactionState {
case .Purchased:
println("Product Purchased");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
break;
case .Failed:
//*ALWAYS FAIL*
println("Purchased Failed");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
break;
// case .Restored:
//[self restoreTransaction:transaction];
default:
break;
}
}
}
}
为什么会发生这种情况,我该如何解决?
答案 0 :(得分:1)
我建议您关注Ray In App Tutorial,请务必遵循以下步骤。
如果你已经确定你通过了正确的方向:
检查您的IAP产品应用ID是否正确。
检查In App Purchases是否通过“功能”部分激活。
确保您的应用通过Itunes Connect连接到应用。