问题
i've searched and can't find any way to create a delay of showing message: "Your purchase was successful" to wait until the validation receipt finished.
I've tried to quote the line SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
but the message still fires.
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("Received Payment Transaction Response from Apple");
for transaction:AnyObject in transactions {
if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
switch trans.transactionState {
case .Purchased:
print("Product Purchased");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
// validate receipt and update money
validateReceipt(trans.payment.productIdentifier)
break;
case .Failed:
print("Purchased Failed");
SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
self.indicator.Hide()
break;
case .Restored:
print("restored")
SKPaymentQueue.defaultQueue().finishTransaction(transaction as! SKPaymentTransaction)
//[self restoreTransaction:transaction];
self.indicator.Hide()
break;
default:
break;
}
}
}
}
回答1:
Basically there is no way to delay the "purchase was successful" message.
But you can show an additional alert after validating the receipt, showing the results of validation to user.
来源:https://stackoverflow.com/questions/37274451/ios-how-to-delay-of-showing-message-purchase-was-successful-to-wait-until-th