使用 StoreKit 时未记录的 NSURLErrorDomain 错误代码(-1001、-1003 和 -1004)
我正在编写与 StoreKit 相关的代码,当我尝试将购买添加到队列时,我收到了一些相当麻烦的错误代码。
到目前为止,我遇到过错误代码 -1003 和 -1004,但我在互联网上找不到有关这些代码的任何信息。
运行产品请求会返回有效的产品编号,因此我不知道为什么调用 [[SKPaymentQueue defaultQueue] addPayment:aPayment];
会因此未记录的问题而失败。
相同的代码在一台设备上也可以正常运行,但在另一台设备上则不然。
到目前为止,我的问题尚未得到解答:
这些代码意味着什么? 我怎样才能缓解这个问题? 为什么它们是针对购买尝试而不是针对产品请求而发生?
我所做的故障排除包括重新生成签名证书和配置文件、更改 WiFi 网络、清理、构建和重新安装所有相关软件和组件,但这些单独或一起都无法帮助解决问题。
编辑:
在Apple开发论坛上找到了关于此问题的讨论,但Apple没有人回复: https://devforums.apple.com/thread/107121?tstart=75(需要 iOS 开发者帐户才能查看)
编辑:
今天我遇到了错误代码 -1001,添加到这个无法解释和间歇性问题的列表中。据我所知,苹果公司仍然没有承担任何责任。
编辑:
我怀疑这些错误代码是随机生成的,实际上仅表明沙盒已关闭。还有其他人遇到这个问题吗?
I'm writing StoreKit-related code, and I'm getting some rather troubling error codes when I try to add a purchase to the queue.
So far, I've experienced error codes -1003 and -1004 and I can't find anything about those codes on the internet.
Running a product request returns valid product numbers, so I don't know why calls to [[SKPaymentQueue defaultQueue] addPayment:aPayment];
would fail with this undocumented problem.
The same code also works without the errors on one device but not on another.
The questions I have are, as of yet, unanswered:
What do these codes mean?
How can I mitigate this problem?
Why are they happening for purchase attempts and not for product requests?
Troubleshooting I've done includes regenerating a signing certificate and provisioning profile, changing WiFi networks, cleaning and building and reinstalling all related software and components, and none of these things individually or together have helped fix the problem.
EDIT:
Found a discussion about this on the Apple dev forums, but no one from Apple has responded: https://devforums.apple.com/thread/107121?tstart=75 (iOS developer account required to view)
EDIT:
I was hit with error code -1001 today, to add to this list of inexplicable and intermittent problems. Still no accountability from Apple, that I can find.
EDIT:
I have a suspicion that these error codes are randomly generated and really only indicate that the Sandbox is down. Anyone else experience this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
所有错误代码都位于文档中的“CFNetwork 错误代码参考”(链接
) CFURL 和 CFURLConnection 错误的提取:
All error codes are on "CFNetwork Errors Codes References" on the documentation (link)
A small extraction for CFURL and CFURLConnection Errors:
我有类似的问题,就我而言似乎与网络连接有关:
要检查的事项:
抱歉,不知道如何解决。只是调试这个,试图找出问题所在(-1021,-1001,-1009)
更新:Google搜索非常好地找到了这个:
I have similar problems, in my case seem to be related to network connectivity:
Things to check:
Sorry, no ideas how to fix. Just debugging this, trying to find out what the problem is (-1021, -1001, -1009)
Update: Google search was very kind to find this:
参见 NSURLError.h 定义
see NSURLError.h Define
我在我的项目中使用以下方法
然后我只检查错误代码并显示警报(如果它在列表中)
但是正如您所看到的,我注释掉了我认为不符合我对无互联网定义的代码。例如代码-1012(身份验证失败。)
您可以根据需要编辑该列表。
在我的项目中,我在用户输入的用户名/密码中使用它。在我看来,(物理)网络连接错误可能是在基于网络的应用程序中显示警报视图的唯一原因。在任何其他情况下(例如不正确的用户名/密码对),我更喜欢做一些自定义的用户友好动画,或者只是再次重复失败的尝试而不引起用户的任何注意。特别是如果用户没有明确发起网络调用。
感谢 martinezdelariva 提供文档链接。
I use the following method in my project
Then I just check the error code and show alert if it is in the list
But as you can see I commented out codes that I think does not fit to my definition of NO INTERNET. E.g the code of -1012 (Authentication fail.)
You may edit the list as you like.
In my project I use it at username/password entering from user. And in my view (physical) network connection errors could be the only reason to show alert view in your network based app. In any other case (e.g. incorrect username/password pair) I prefer to do some custom user friendly animation, OR just repeat the failed attempt again without any attention of the user. Especially if the user didn't explicitly initiated a network call.
Regards to martinezdelariva for a link to documentation.
我发现了一个上面未记录的新错误代码:
CF网络错误代码-1022
I found a new error code which is not documented above:
CFNetworkErrorCode -1022
我在文档中找到了此页面,其中包含 NSURLErrorDomain 下所有错误代码的 Objective-C 枚举。
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/URL_Loading_System_Error_Codes
I found this page in the documentation which has an objective-c enum for all of the error codes under the NSURLErrorDomain.
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Constants/index.html#//apple_ref/doc/constant_group/URL_Loading_System_Error_Codes
以下站点对于查找未记录或难以找到的 Apple API 错误代码也非常有用:
https://www.osstatus。 com/
您可以仅提供错误代码(例如 -1001 或
kCFURLErrorTimedOut
),甚至可以提供您正在使用的框架或 API(例如CFNetwork
、NSURL
或AVAudioSession
),该网站将列出与您的搜索匹配的所有潜在错误,显示错误名称、相关框架和定义错误的头文件。The following site is also very useful for finding undocumented or hard to find Apple API error codes:
https://www.osstatus.com/
You can supply just the error code (such as -1001 or
kCFURLErrorTimedOut
) or even the Framework or API you are using (such asCFNetwork
,NSURL
orAVAudioSession
) and the site will list all potential errors that match your search, showing the error names, relevant Framework and header files in which the error(s) are defined.