在我的Xcode控制台中收到这条消息:“忽略restoreCompletedTransactionsWithApplicationUsername:因为已经在恢复交易”,该怎么办?

3

当我点击恢复购买按钮时,我收到了以下信息。这是我用于恢复购买的代码......请问是否有做错的地方?谢谢!顺便说一下,如果您需要更多信息或代码,请告诉我。

忽略restoreCompletedTransactionsWithApplicationUsername:因为已经在恢复交易

func RestorePurchases() {
    if SKPaymentQueue.canMakePayments() {
        SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
    } else {
        println("Can't make purchases")
    }
}


   func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
    var purchasedItemIDS = []
    for transaction in queue.transactions {
        var t: SKPaymentTransaction = transaction as! SKPaymentTransaction

        let prodID = t.payment.productIdentifier as String

        switch prodID {
        case "unlockLevelTwo":
            println("restoreleveltwo")
            unlockLevelTwoPlease()
        case "unlockLevelThree":
            println("restorelevelthree")
            unlockLevelThreePlease()
        default:
            println("IAP not setup")

        }

    }

}


   override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {



    var touch: UITouch = touches.first as! UITouch
    var location = touch.locationInNode(self)
    var node = self.nodeAtPoint(location)


    if node.name == "restore" {
        runAction(menuAudioPlayer)
        RestorePurchases()
    }
1个回答

1

一旦恢复了交易,您从未使用 finishTransaction: 调用该事务,因此它仍然留在支付队列中。

来自此方法的文档

您的应用程序应该从接收到来自支付队列的通知的事务观察者中调用此方法。在事务上调用 finishTransaction: 将其从队列中删除。仅在成功处理交易并解锁用户购买的功能后,您的应用程序才应调用 finishTransaction:


我已经在我的代码中有它了... 我忘记发布它了: func finishTransaction(trans: SKPaymentTransaction) { println("完成交易") SKPaymentQueue.defaultQueue().finishTransaction(trans) } - coding22
我应该在哪里添加finishTransaction:@AaronBrager - coding22
@coding22 在文档中的描述是:“在您的应用程序成功处理交易并解锁用户购买的功能之后”。 - Aaron Brager
@coding22 是的,但我建议你先自己尝试一下(这样你会学到更多)。 - Aaron Brager
我已经让它工作了,但是当我点击其中一个解锁的关卡时,它会崩溃。在控制台上,当我这样做时,它会显示 false。@aaronbrager - coding22
显示剩余5条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接