【问题标题】:In App Purchase: Can not track process CANCEL or SUCCESS应用内购买:无法跟踪进程取消或成功
【发布时间】:2016-09-13 15:19:58
【问题描述】:

当我在沙盒中使用 IAP 进行测试时,我有 2 种情况:

  • 案例1:如果我购买成功。 transaction.state 切换到Purchased 键。
  • 案例 2:如果我在 Iphone 要求我登录 Apple ID 或接受付款时取消。 transaction.state 也切换到Purchased 键。

如何解决我的问题?如何知道用户取消与否? 谢谢!

更新: 当我在模拟器中测试时,当我取消 In App Purchase 请求 Apple ID 时,SKPaymentTransactionState 切换到 Failed

但是,当我在真实设备中测试时,当我取消应用内购买请求 Apple ID 时,SKPaymentTransactionState 会切换为Purchasedtransaction.error 总是nil

我不知道为什么。

更新:

  • 我无法跟踪 TransactionState,因为我使用了已越狱的老板设备并使用 Local validate Receipt 。我的天啊。
  • 感谢您的帮助

【问题讨论】:

    标签: ios transactions swift2 in-app-purchase


    【解决方案1】:

    试试这个

    if (transaction.error.code == SKErrorPaymentCancelled)
        {
                NSLog(@"Transaction error: %@", transaction.error.localizedDescription);
        }
    

    更多,

    switch (transaction.error.code) {
        case SKErrorUnknown:
            //Unknown error
            break;
        case SKErrorClientInvalid:
            // client is not allowed to issue the request, etc.
            break;
        case SKErrorPaymentCancelled:
            // user cancelled the request, etc.
            break;
        case SKErrorPaymentInvalid:
            // purchase identifier was invalid, etc.
            break;
        case SKErrorPaymentNotAllowed:
            // this device is not allowed to make the payment
            break;
        default:
            break;
    }
    

    【讨论】:

    • 抱歉我最近的回复。因为我没有要测试的设备。我试试你的方法,但是。 transaction.error.code 总是 nil
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 2015-12-09
    • 2021-07-10
    • 2013-10-06
    相关资源
    最近更新 更多