ios iPhone 应用内购买商店套件错误 -1003“无法连接到 iTunes Store”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1717700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iPhone In-App Purchase Store Kit error -1003 "Cannot connect to iTunes Store"
提问by Rei
I've been working on adding in-app purchases and was able to create and test in-app purchases using Store Kit (yay!). During testing, I exercised my app in a way which caused the app to crash mid purchase (so I guess the normal cycle of receiving paymentQueue:updatedTransactions and calling finishTransaction was interrupted).
我一直致力于添加应用内购买,并且能够使用 Store Kit 创建和测试应用内购买(是的!)。在测试期间,我以一种导致应用程序在购买过程中崩溃的方式运行我的应用程序(所以我猜接收 paymentQueue:updatedTransactions 和调用 finishTransaction 的正常周期被中断了)。
Now I am unable to successfully complete any transactions and instead am getting only transactions with transactionState SKPaymentTransactionStateFailed when paymentQueue:updatedTransactions is called.
现在我无法成功完成任何交易,而是在调用 paymentQueue:updatedTransactions 时只获取 transactionState SKPaymentTransactionStateFailed 的交易。
The transaction.error.code is -1003 and the transaction.error.localizedDescription is "Cannot connect to iTunes Store"!
transaction.error.code 是 -1003,transaction.error.localizedDescription 是“无法连接到 iTunes Store”!
I have tried removing all products from iTunesConnect, and rebuilt them using different identifiers but that did not help. I have also tried using the App Store app to really connect to the real App Store and download some apps so I do have connectivity. Finally, I have visited the Settings:Store app to make sure I am signed out of my normal app store account.
我尝试从 iTunesConnect 中删除所有产品,并使用不同的标识符重建它们,但这没有帮助。我还尝试使用 App Store 应用程序来真正连接到真正的 App Store 并下载一些应用程序,这样我就可以连接了。最后,我访问了 Settings:Store 应用程序以确保我已退出正常的应用程序商店帐户。
回答by Ortwin Gentz
I had a similar situation and dumped the iPhone's network traffic to see what's going on. I found that the normal store was contacted instead of the sandbox. It helped to delete the app from the device, make clean and build/install it again. Apparently something with the development profile had gone wrong.
我遇到了类似的情况并转储了 iPhone 的网络流量以查看发生了什么。我发现联系的是普通商店而不是沙箱。它有助于从设备中删除应用程序,清理并重新构建/安装它。显然,开发配置文件出了问题。
Update:To dump the network traffic of a non-jailbroken iPhone, just use Internet Sharing on your Mac and configure your iPhone to use your Mac's WiFi. Then tcpdump -n -i en1
on your Mac will do the trick.
更新:要转储未越狱 iPhone 的网络流量,只需在 Mac 上使用 Internet 共享并将 iPhone 配置为使用 Mac 的 WiFi。然后tcpdump -n -i en1
在你的 Mac 上就可以了。
回答by Adam Rosenfield
If you're getting error 0 "Cannot connect to iTunes Store" (which I realize is not the error -1003 that OP asked about, but a web search for error 0 also leads here), this can be caused by two possible problems:
如果您收到错误 0“无法连接到 iTunes Store”(我意识到这不是 OP 询问的错误 -1003,但网络搜索错误 0 也会导致此处),这可能是由两个可能的问题引起的:
- You're passing in the wrong product identifier. If that's the case, then you'll get error 0 shortly after calling
-[SKPaymentQueue addPayment:]
, before you get the popup asking you to confirm payment. - Your test user has become invalidated. This can happen if you accidentally log into the App Store with your test user. When this happens, you'll get error 0 after entering your password to confirm your payment.
- 您传入了错误的产品标识符。如果是这种情况,那么您将在调用 后不久收到错误 0,然后您会收到
-[SKPaymentQueue addPayment:]
要求您确认付款的弹出窗口。 - 您的测试用户已失效。如果您不小心与测试用户一起登录 App Store,就会发生这种情况。发生这种情况时,您会在输入密码以确认付款后收到错误 0。
To fix problem #1, pass in the correct product ID. To fix problem #2, create a new test user on iTunes Connect, and optionally delete the old test user.
要解决问题 #1,请传入正确的产品 ID。要解决问题 #2,请在 iTunes Connect 上创建一个新的测试用户,并可以选择删除旧的测试用户。
回答by thomax
I had a similar issue, was getting "Cannot connect to iTunes Store" with Code=0. This is how I solved it, after trying every other ritualistic piece of advice found on the Internet from re-downloading my certificates to resetting all my device settings to sacrificing a virgin black goat:
我有一个类似的问题,代码=0 时出现“无法连接到 iTunes Store”。在尝试了从重新下载我的证书到重置我的所有设备设置再到牺牲一只处女黑山羊的互联网上所有其他仪式性建议之后,我就是这样解决的:
In the target summary for the app, I used to have my version number in the "build" field, but nothing in "version" field. This seemed odd to me, so I moved the version number from "build" to "version". This resulted in the aforementioned error. Moving the version number back to "build" solved the error.
在应用程序的目标摘要中,我曾经在“构建”字段中有我的版本号,但在“版本”字段中没有。这对我来说似乎很奇怪,所以我将版本号从“build”移到了“version”。这导致了上述错误。将版本号移回“build”解决了错误。
回答by HelloWorld
Add new test user for your app.
为您的应用添加新的测试用户。
回答by k3a
Make sure you have correct date and time set in the Settings. otherwise it fails to make a SSL conenction to the store!!
确保您在“设置”中设置了正确的日期和时间。否则无法与商店建立 SSL 连接!!
回答by Christopher Pickslay
I had the same error, and after reading through some threads on the developer forums, I reset the settings on my device (Settings->General->Reset->Reset All Settings), which cleared it up. It seemed drastic, but it worked.
我遇到了同样的错误,在阅读了开发者论坛上的一些帖子后,我重置了设备上的设置(设置->常规->重置->重置所有设置),这将其清除。这看起来很激烈,但它奏效了。
回答by frandogger
I had the same error that seemed to pop up out of nowhere (was working fine one day, but then the next day it was giving me these errors about 2 out of every 3 times I tried testing my in-app purchase).
我有同样的错误,似乎无处不在(一天工作正常,但第二天它给我这些错误大约每 3 次我尝试测试我的应用程序内购买的 2 次)。
Then I visited the App Store (when trying to make another real purchase), and realized that they had a new user agreement that they wanted me to verify. After I did that, when I went back to my own app and tried out the test purchase again, it was working fine and have had no errors since. So I suspect I was getting the error because they wanted me to verify the new user agreement.
然后我访问了 App Store(尝试进行另一次真正的购买时),并意识到他们有一个新的用户协议,他们希望我验证。在我这样做之后,当我回到我自己的应用程序并再次尝试测试购买时,它运行良好并且从那时起没有错误。所以我怀疑我收到错误是因为他们想让我验证新的用户协议。
Now the only thing I wonder is if there is a way for my in-app purchase to forward that prompt to my users instead of giving them a mysterious error?
现在我唯一想知道的是,我的应用内购买是否有办法将该提示转发给我的用户,而不是给他们一个神秘的错误?
回答by Naveen Shan
In SKPaymentTransactionState
tells that SKPaymentTransactionStateFailed
before your request is added to server queue.
InSKPaymentTransactionState
告诉SKPaymentTransactionStateFailed
您在将请求添加到服务器队列之前。
@class SKPayment;
enum {
SKPaymentTransactionStatePurchasing, // Transaction is being added to the server queue.
SKPaymentTransactionStatePurchased, // Transaction is in queue, user has been charged. Client should complete the transaction.
SKPaymentTransactionStateFailed, // Transaction was cancelled or failed before being added to the server queue.
SKPaymentTransactionStateRestored // Transaction was restored from user's purchase history. Client should complete the transaction.
};
typedef NSInteger SKPaymentTransactionState;
And on SKPaymentTransaction
Class Reference Error Discussion says:
并在SKPaymentTransaction
类参考错误讨论中说:
The error property is undefined except when transactionState is set to SKPaymentTransactionStateFailed
. Your application can read the error property to determine why the transaction failed.
error 属性未定义,除非 transactionState 设置为SKPaymentTransactionStateFailed
。您的应用程序可以读取错误属性来确定事务失败的原因。
So, transaction.error.localizedDescription is "Cannot connect to iTunes Store"!is a general error message.. I am also getting this error message regularly while testing my InApp Purchases.
因此,transaction.error.localizedDescription 是“无法连接到 iTunes Store”!是一般错误消息。我在测试我的应用内购买时也经常收到此错误消息。
Some tips u can do is,
你可以做的一些提示是,
Retrieve all products from app store using
SKProductsRequest
and check itsresponse.products
contain your requestedproductIdentifier
. for this use,SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[objProducts allKeys]]]; //pass product identifier array as argument [request start];
使用应用程序商店检索所有产品
SKProductsRequest
并检查其是否response.products
包含您请求的productIdentifier
. 为此用途,SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[objProducts allKeys]]]; //pass product identifier array as argument [request start];
And Catch response in :
并在以下位置捕获响应:
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
NSArray *myProduct = response.products;
}
So that you can decide is you can communicate to app store. and your product id is there.
这样您就可以决定是否可以与应用商店沟通。您的产品 ID 就在那里。
- Make sure that you use In App test user account for testing.
- And you use the same app-id provisioning that you configured In App purchase.
- 确保您使用 In App test 用户帐户进行测试。
- 并且您使用与您配置的应用内购买相同的应用 ID 配置。
thanks
谢谢
回答by lifjoy
What worked for me was to uninstall my app from the test device, then install a fresh copy from Xcode.
对我有用的是从测试设备上卸载我的应用程序,然后从 Xcode 安装一个新副本。
回答by wasabi
I Did a Clean all Targets in XCode and manually deleted the application off my device, then Build and Run from XCode and it fixed a similar problem (Same error message but different error code:-1009)
我在 XCode 中清理了所有目标并手动删除了我的设备上的应用程序,然后从 XCode 构建和运行它修复了一个类似的问题(相同的错误消息但不同的错误代码:-1009)