restoreCompletedTransactionsFailedWithError:取消时出现错误代码0(SKErrorUnknown) [英] restoreCompletedTransactionsFailedWithError: Error Code 0 (SKErrorUnknown) on Cancel

查看:2093
本文介绍了restoreCompletedTransactionsFailedWithError:取消时出现错误代码0(SKErrorUnknown)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上,我希望在某些特定于网络/ iTunes的情况下恢复已完成的交易失败时显示警告,但是当用户点击Apple ID /密码上的取消时,提示。

So basically, I want to display an alert when the restoring of completed transactions fails for some network/iTunes-specific reason, but not when the user taps 'Cancel' on the Apple ID/Password prompt.

在我的执行中:

- (void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error

...我正在测试 error.code 针对 SKErrorPaymentCancelled (也许我也应该针对 SKErrorPaymentNotAllowed ,但现在不相关了)。

...I am testing error.code against SKErrorPaymentCancelled (perhaps I should also test against SKErrorPaymentNotAllowed, but that's not relevant now).

但是,当点击取消时,警报显示无论如何。 NS-Logging其值显示 error.code == 0 (即 SKErrorUnknown )。

Still, the alert showed anyway when tapping 'cancel'. NS-Logging its value showed that error.code == 0 (i.e., SKErrorUnknown).

这发生在iOS 4.3.1,Xcode 4.2,build 4C199(沙盒商店,当然)上。

This is happening on iOS 4.3.1, Xcode 4.2, build 4C199 (sandbox store, of course).

我检查过类似的问题,但回答的是我的案例中没有发生的事情(也就是说,我已经在做的事情应该产生正确的行为)......任何想法?

I have checked similar questions, but what is answered there is not what is happening in my case (that is, what I'm already doing should yield the correct behavior)... Any ideas?

推荐答案

检查这些。应该足够了。

Check against these. Should be enough.

// error codes for the SKErrorDomain
enum {
    SKErrorUnknown,
    SKErrorClientInvalid,       // client is not allowed to issue the request, etc.
    SKErrorPaymentCancelled,    // user cancelled the request, etc.
    SKErrorPaymentInvalid,      // purchase identifier was invalid, etc.
    SKErrorPaymentNotAllowed    // this device is not allowed to make the payment
};

来自 https://stackoverflow.com/a/9017990/129202

所以我做的是我在error.code上进行切换,并且仅代码不是SKErrorPaymentCancelled时显示错误。用户可能知道他/她按下了取消按钮(当输入用户/通行证时)。

So what I do is I do a switch on the error.code, and only show an error when the code is not SKErrorPaymentCancelled. The user probably knows he/she pushed the cancel button (when entering user/pass).

所以 SKErrorPaymentCancelled 应该赶上取消。如果取消按钮抛出另一个错误代码,那么iOS版本有问题吗?

So SKErrorPaymentCancelled should catch the cancel. If cancel button throws another error code, then there's a problem with that iOS version?

这篇关于restoreCompletedTransactionsFailedWithError:取消时出现错误代码0(SKErrorUnknown)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆