Swift Store Kit在应用程序中购买transactionState

时间:2015-05-29 14:13:27

标签: ios swift in-app-purchase storekit

我制作的应用程序使用商店套件添加一些字符..

我添加了paymentQueue功能,但是当显示弹出窗口并按Cancel时,transactionState为.Completed

在此方法中,如果用户取消交易,则无需支付即可获得该字符。

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
    println("add paymnet")

    for transaction:AnyObject in transactions {
        var trans = transaction as SKPaymentTransaction


        switch trans.transactionState {

        case .Purchased:
            println("Purchase Successful")
            SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
            queue.finishTransaction(trans)
            break;
        case .Failed:
            println("Buy Cancelled")
            SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
            queue.finishTransaction(trans)
            break;
        default:
            println("default")
            break;

        }
    }
}

This is the link of the tutorial i followed

在真实设备和沙箱用户上测试功能。

0 个答案:

没有答案