iPhone 应用内购买商店工具包错误 -1003“无法连接到 iTunes Store”

发布于 2024-08-11 01:58:03 字数 541 浏览 5 评论 0原文

我一直致力于添加应用内购买,并且能够使用 Store Kit 创建和测试应用内购买(耶!)。在测试期间,我以一种导致应用程序在购买过程中崩溃的方式运行了我的应用程序(所以我猜接收 paymentQueue:updatedTransactions 和调用 finishTransaction 的正常周期被中断了)。

现在,我无法成功完成任何交易,而是在调用 paymentQueue:updatedTransactions 时仅获取 transactionState SKPaymentTransactionStateFailed 的交易。

transaction.error.code 为 -1003,transaction.error.localizedDescription 为“无法连接到 iTunes Store”!

我尝试从 iTunesConnect 中删除所有产品,并使用不同的标识符重建它们,但这没有帮助。我还尝试使用 App Store 应用程序真正连接到真正的 App Store 并下载一些应用程序,这样我就可以连接了。最后,我访问了“设置:商店”应用程序,以确保我已退出正常的应用程序商店帐户。

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).

Now I am unable to successfully complete any transactions and instead am getting only transactions with transactionState SKPaymentTransactionStateFailed when paymentQueue:updatedTransactions is called.

The transaction.error.code is -1003 and the transaction.error.localizedDescription is "Cannot connect to 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(20

毁我热情 2024-08-18 01:58:03

我也遇到过类似的情况,我把iPhone的网络流量转储看看到底是怎么回事。我发现联系的是普通商店而不是沙箱。它有助于从设备中删除应用程序,进行清理并再次构建/安装它。显然开发配置文件出了问题。

更新:要转储未越狱 iPhone 的网络流量,只需在 Mac 上使用互联网共享并将 iPhone 配置为使用 Mac 的 WiFi。然后 Mac 上的 tcpdump -n -i en1 就可以了。

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.

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 en1on your Mac will do the trick.

安静被遗忘 2024-08-18 01:58:03

如果您收到错误 0“无法连接到 iTunes Store”(我意识到这不是 OP 询问的错误 -1003,但网络搜索错误 0 也会导致此处),这可能是由两个可能的问题引起的:

  1. 您传递了错误的产品标识符。如果是这种情况,那么在调用 -[SKPaymentQueue addPayment:] 后不久,您将收到错误 0,然后弹出窗口要求您确认付款。
  2. 您的测试用户已失效。如果您意外地使用测试用户登录 App Store,则可能会发生这种情况。发生这种情况时,您在输入密码确认付款后会收到错误 0。

要解决问题 1,请传入正确的产品 ID。要解决问题 #2,请在 iTunes Connect 上创建一个新的测试用户,并可以选择删除旧的测试用户。

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:

  1. 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.
  2. 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.

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.

听你说爱我 2024-08-18 01:58:03

我遇到了类似的问题,收到“无法连接到 iTunes Store”且代码=0。这就是我解决这个问题的方法,在尝试了互联网上找到的所有其他仪式性建议之后,从重新下载我的证书到重置所有设备设置,再到牺牲一只处女黑山羊:

在应用程序的目标摘要中,我曾经有我的版本号在“构建”字段中,但“版本”字段中没有任何内容。这对我来说似乎很奇怪,所以我将版本号从“build”移至“version”。这导致了上述错误。将版本号移回“build”解决了该错误。

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:

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.

倒数 2024-08-18 01:58:03

为您的应用程序添加新的测试用户。

Add new test user for your app.

静若繁花 2024-08-18 01:58:03

确保您在“设置”中设置了正确的日期和时间。否则无法与商店建立 SSL 连接!

Make sure you have correct date and time set in the Settings. otherwise it fails to make a SSL conenction to the store!!

§普罗旺斯的薰衣草 2024-08-18 01:58:03

我遇到了同样的错误,在阅读了开发者论坛上的一些帖子后,我重置了设置在我的设备上(设置->常规->重置->重置所有设置),这清除了它。这看起来很激烈,但确实有效。

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.

初见 2024-08-18 01:58:03

我也遇到了同样的错误,似乎不知从何而来(有一天工作正常,但第二天,在我尝试测试应用内购买时,大约每 3 次就会出现这些错误)。

然后我访问了应用程序商店(当尝试进行另一次真正的购买时),并意识到他们有一个新的用户协议,他们希望我验证。完成此操作后,当我返回自己的应用程序并再次尝试购买测试时,它工作正常并且从那以后没有出现任何错误。所以我怀疑我收到错误是因为他们希望我验证新的用户协议。

现在我唯一想知道的是,是否有一种方法可以让我的应用内购买将该提示转发给我的用户,而不是给他们一个神秘的错误?

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).

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.

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?

多孤肩上扛 2024-08-18 01:58:03

对我有用的是从测试设备上卸载我的应用程序,然后从 Xcode 安装一个新的副本。

What worked for me was to uninstall my app from the test device, then install a fresh copy from Xcode.

笑着哭最痛 2024-08-18 01:58:03

SKPaymentTransactionState 中,在您的请求添加到服务器队列之前告知 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;

SKPaymentTransaction类参考错误讨论中说:

错误属性是未定义的,除非transactionState设置为SKPaymentTransactionStateFailed。您的应用程序可以读取错误属性来确定事务失败的原因。

因此,transaction.error.localizedDescription 是“无法连接到 iTunes Store”! 是一条常规错误消息。我在测试应用内购买时也经常收到此错误消息。

您可以做的一些提示是,

  1. 使用SKProductsRequest从应用商店检索所有产品,并检查其response.products包含您请求的productIdentifier
    对于这种用途,

    SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithArray:[objProducts allKeys]]];
    //传递产品标识符数组作为参数
    [请求开始];  
    

并捕获响应:

    - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
        NSArray *myProduct = response.products;
}

以便您可以决定是否可以与应用程序商店进行通信。您的产品 ID 就在那里。

  1. 确保您使用应用内测试用户帐户进行测试。
  2. 并且您使用与您配置的应用程序内购买相同的应用程序 ID 配置。

谢谢

In SKPaymentTransactionState tells that SKPaymentTransactionStateFailed before your request is added to server queue.

@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:

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.

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.

Some tips u can do is,

  1. Retrieve all products from app store using SKProductsRequest and check its response.products contain your requested productIdentifier.
    for this use,

    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.

  1. Make sure that you use In App test user account for testing.
  2. And you use the same app-id provisioning that you configured In App purchase.

thanks

歌枕肩 2024-08-18 01:58:03

我尝试前往 App Store,然后返回“设置/商店”以注销。我这样做了 3 次,每次都重新访问我的应用程序并添加调试 NSLog 输出,现在我可以继续测试我的应用程序内购买代码,不会出现错误 -1003。我不确定再次工作的确切原因,但我相当确定这不是我的代码更改,因为我所做的只是添加 NSLogs 并重新运行我的应用程序。

I fiddled around with going to the App Store and then back to Settings/Store to Sign Out. I did this 3 times, revisiting my app each time and adding debugging NSLog output, and now I am able to continue testing my in-app purchase code without error -1003. I am not sure the exact reason for this working again, but I am fairly certain is is not a code change on my part as all I was doing was adding NSLogs and re-running my app.

盛夏已如深秋| 2024-08-18 01:58:03

是的,如果您最初将 iPad/iPhone 连接到另一台计算机,现在在另一台计算机上使用它,则绝对必须在 iPad 上退出商店,在 Mac 上使用普通帐户登录 iTunes,然后同步。

另外,请确保您的 iPad“WIFI”已开启...

Yeah, IF you've connected your iPad/iPhone to a different computer initially, and are now using it on another, you absolutely must sign out of store on your iPad, sign in w/ normal account to ITunes on your MAC, then Sync.

Also, make sure your iPad "WIFI" is on...

守望孤独 2024-08-18 01:58:03

我在 XCode 中清理了所有目标,并手动从我的设备中删除了该应用程序,然后从 XCode 构建并运行,它修复了类似的问题(相同的错误消息,但不同的错误代码:-1009)

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)

喜你已久 2024-08-18 01:58:03

不幸的是,我遇到了一个这里没有记录的问题。在您接受与应用程序和应用程序内购买相关的所有合同之前,应用程序内购买将无法运行。因此,请确保您(或您的客户)在 iTunesConnect 中正确设置所有合同,它们必须出现在“有效合同”部分中才能使您的购买生效。

Unfortunately, I ran into a problem that was not documented here. In-App-Purches will not work until you accepted all contracts related to app- and in-app-purcheses. So make sure you (or your customer) set up all contracts in iTunesConnect properly, they must appear in the "Contracts In Effect" section to make your purchaes work.

谈下烟灰 2024-08-18 01:58:03

我们的问题是在 Itunes Connect 中我们有错误的包标识符。有人事先创建了该应用程序,我们必须编辑该应用程序并将其 appId 设置为新的。

Our problem was that in Itunes Connect we had the wrong bundle identifier. Someone had created the app before hand and we had to edit the app and set its appId to the new one.

安稳善良 2024-08-18 01:58:03

我有两个问题导致了这个问题:

1)我从另一个(工作)应用程序复制了 IAP 代码,但错过了设置我的观察者:

observer = [[IAPHelper alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

2) 我在设备的设置中登录了 iTunes。您只能在沙箱中使用测试用户 - 我注销后它又可以工作了。

I had two problems that caused this:

1) I had copied the IAP code from a different (working) app but had missed setting up my observer:

observer = [[IAPHelper alloc] init];
[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

2) I was logged in to iTunes in the settings of my device. You can only use a test user in the sandbox - I logged out and it worked again.

—━☆沉默づ 2024-08-18 01:58:03

只需注销您的 iTunes 帐户(现在不要登录您的测试帐户!),然后启动您的程序。当应用内购买时,它会询问您的登录详细信息,您必须输入您的测试帐户信息。

Just log out your iTunes account (don't login your test account now! ) , and start your program. When inapp purchase it ask your login details, you must enter your test account information.

相思碎 2024-08-18 01:58:03

我尝试了这里线程中提供的所有解决方案,但无济于事。就我而言,我有一个通配符捆绑包标识符,其域名与我在为应用内购买配置文件创建捆绑包标识符时使用的域名相同。

以下是我解决问题的方法,可能会帮助您解决问题(请参阅附件):

1) 将 iPhone 连接到 Mac。

2) 在“设备”下(在 Xcode > 窗口菜单 > 管理器窗口中),为您的 iPhone 选择“配置配置文件”选项。您将看到当前驻留在 iPhone 上的所有配置文件。

3) 小心删除以捆绑标识符 (com.MYDOMAIN.*) 中的特定域名开头的所有配置文件,尤其是使用通配符的配置文件,您专门创建的具有应用内购买功能的配置文件 (com .MYDOMAIN.inappidentifier)。

4) 重新安装应用程序并使用新的 iTunes 连接测试用户(沙盒)测试您的实施情况

屏幕截图:

在此处输入图像描述

I tried every solution offered in the thread here, but to no avail. In my case, I had a wild-card bundle identifier starting with the same domain name as the one I used while creating the bundle identifier for in-app purchase provisioning profile.

Here is how I fixed the problem and may help you fix yours (See attached):

1) Connect your iPhone to Mac.

2) Under the "Devices" (in Xcode > Window menu > Organizer window) select the "Provisioning Profiles" option for your iPhone. You will see all provisioning profiles currently residing on your iPhone.

3) Carefully remove all provisioning profiles starting with the particular domain name in the bundle identifier (com.MYDOMAIN.*) especially the ones that use wild-card except for the one you create specifically with the ability to do In-App purchase (com.MYDOMAIN.inappidentifier).

4) Install the app afresh and test your implementation with a fresh iTunes connect test user (sandbox)

SCREENSHOT:

enter image description here

眼眸里的快感 2024-08-18 01:58:03

我已经被困了 2 天,这是我的解决方案:

  1. 删除所有应用内产品。
  2. 删除新的应用内产品。
  3. 创建沙箱测试器。
  4. 从设备(iPad)上注销我的苹果帐户,然后尝试购买该产品。
  5. 它将要求登录,然后使用沙箱测试人员帐户重新登录。
  6. 购买通过。

我认为重要的是沙箱测试者帐户,我以前没有使用过它,因为我总是得到错误0。

I have been stuck for 2 days, here's my solution:

  1. Remove all in-app-products.
  2. Remove new in-app-products.
  3. Create a sandbox tester.
  4. Log out my apple account from device (iPad), and then try to buy the product.
  5. It will ask for login, then re-login with the sandbox tester account.
  6. Purchase goes through.

I think the importance is the sandbox tester account, I have not used it before since I always got error-0.

那片花海 2024-08-18 01:58:03

就我而言,
我尝试了互联网上的所有方法,但没有任何效果。

苹果实际上打破了生产支付系统和沙箱。我只等了两天,它就开始起作用了。

In my case,
I tried everything in the internet, but nothing worked.

Apple actually broke the production payment system, and the sandbox. I just had to wait two days, and it started to work.

亚希 2024-08-18 01:58:03

应用内购买常见问题解答说:

无法连接到 iTunes Store

“无法连接到 iTunes Store”问题可能是由于以下一个或多个原因造成的:

  • 沙箱可能无法访问。
  • 您的应用没有捆绑版本 (CFBundleVersion)。有关详细信息,请参阅设置版本号和构建字符串。
  • 您的应用正在模拟器中运行,该模拟器不支持应用内购买。
  • 您正在尝试购买无法销售的产品。有关详细信息,请参阅在显示应用商店 UI 之前查询 App Store 以获取产品信息。

就我而言,发生错误是因为我使用的是 Xcode 模拟器。当我使用我的设备时它开始工作。

即使在 应用内购买编程指南说使用开发iOS设备有一个建议的测试步骤

The In-App Purchase FAQ says:

Cannot connect to iTunes Store

The "Cannot connect to iTunes Store" issue may be due to one or more of the following reasons:

  • The sandbox may be unreachable.
  • Your app does not have a bundle version (CFBundleVersion). See Setting the Version Number and Build String for more information.
  • Your app is running in the Simulator, which does not support in-app purchase.
  • You are attempting to purchase a product that is unavailable for sale. See Query the App Store for product information before presenting your app’s store UI for more information.

In my case, the error occurred because I was using the Xcode simulator. It started working when I used my device.

Even in the In-App Purchase Programming Guide says to use the development iOS device has a suggested testing step.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文