1

store.purchase() 在所有情况下总是超时/返回吗?

那就是我可以确信我可以离开带有微调器的模态对话框等待此调用的响应吗?

(在http://docs.coronalabs.com/daily/api/library/store/purchase.html#store.purchase的文档中并没有真正说明这一点)

4

2 回答 2

3

是的,它确实。当您使用store.init( [storeName,] listener )您指定商店名称和交易的回调函数(即store.init("apple", transactionCallback). 在此回调函数中,您可以检查某些事务状态。

local function transactionCallback( event )
    local transaction = event.transaction
    print("EVENT:PHASE = " .. transaction.state)

    if transaction.state == "purchased" then
        print("Transaction succuessful!")
        print("productIdentifier", transaction.productIdentifier)
        print("receipt", transaction.receipt)
        print("signature", transaction.signature)
        print("transactionIdentifier", transaction.identifier)
        print("date", transaction.date)
    elseif  transaction.state == "restored" then
        print("Transaction restored (from previous session)")
        print("signature", transaction.signature)        
        print("productIdentifier", transaction.productIdentifier)
        print("receipt", transaction.receipt)
        print("transactionIdentifier", transaction.identifier)
        print("date", transaction.date)
        print("originalReceipt", transaction.originalReceipt)
        print("originalTransactionIdentifier", transaction.originalIdentifier)
        print("originalDate", transaction.originalDate)
    elseif transaction.state == "cancelled" then
        print("User cancelled transaction")
    elseif transaction.state == "failed" then
        print("Transaction failed, type:", transaction.errorType, transaction.errorString)
    else
        print("unknown event")
    end
end
于 2013-10-29T07:57:31.783 回答
0

是的,但如果它感知到某种类型的互联网连接(甚至是糟糕的连接),它将保持对话直到收到响应,并且考虑到在移动互联网上玩游戏的玩家经常连接不佳。如果在合理的时间内没有收到响应,您可能想要插入一个 Corona 计时器来取消该过程并通过对话框通知用户。

于 2014-09-03T06:08:20.950 回答