应用程序内购买:无法跟踪进程取消或成功
In App Purchase: Can not track process CANCEL or SUCCESS
当我在sandBox中使用IAP测试时,我有2种情况:
- 情况一:如果我购买成功。
transaction.state
切换到 Purchased
键。
- 情况2:如果我在Iphone要求我登录Apple ID或接受付款时取消。
transaction.state
也切换到 Purchased
键。
如何解决我的问题?如何知道用户是否取消?
谢谢!
更新:
当我在模拟器中测试时,当我取消 In App Purchase 请求 Apple ID 时 SKPaymentTransactionState
切换到 Failed
。
但是,当我在真实设备上测试时,当我取消 In App Purchase 请求 Apple ID 时,SKPaymentTransactionState
切换到 Purchased
。 transaction.error
总是nil
.
我不知道为什么。
更新:
- 我无法跟踪 TransactionState,因为我使用了已越狱并使用 Local validate Receipt 的 boss 设备。我的天啊。
- 感谢您的帮助
试试这个
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;
}
当我在sandBox中使用IAP测试时,我有2种情况:
- 情况一:如果我购买成功。
transaction.state
切换到Purchased
键。 - 情况2:如果我在Iphone要求我登录Apple ID或接受付款时取消。
transaction.state
也切换到Purchased
键。
如何解决我的问题?如何知道用户是否取消? 谢谢!
更新:
当我在模拟器中测试时,当我取消 In App Purchase 请求 Apple ID 时 SKPaymentTransactionState
切换到 Failed
。
但是,当我在真实设备上测试时,当我取消 In App Purchase 请求 Apple ID 时,SKPaymentTransactionState
切换到 Purchased
。 transaction.error
总是nil
.
我不知道为什么。
更新:
- 我无法跟踪 TransactionState,因为我使用了已越狱并使用 Local validate Receipt 的 boss 设备。我的天啊。
- 感谢您的帮助
试试这个
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;
}