iOS - How to delay of showing message “purchase was successful” to wait until the validation receipt finished

。_饼干妹妹 提交于 2019-12-22 10:07:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!