In-App Purchase Error Code 0

…衆ロ難τιáo~ 提交于 2019-12-06 04:06:02

问题


I'm trying to troubleshoot why I'm getting "Cannot connect to iTunes Store" with error code 0.

I know my app identifier is fine because I retrieve product information on app launch and log the results and I get the correct product identifiers and prices from iTunes. When I change my app identifier to something stupid this fails.

I know my product identifiers are fine as well for the above reasons (it wouldn't work otherwise and I double checked).

I have tried firing the purchase by creating an SKPayment in 2 different ways:

FIRST WAY

SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier]; // This is deprecated in ios 5 but should work
[[SKPaymentQueue defaultQueue] addPayment:payment];

SECOND WAY

SKPayment *payment = [SKPayment paymentWithProduct:foundProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];

(foundProduct is from the array of SKProducts that get returned from an SKProductsRequest)

Both ways fail with error code 0.

I've tried this both on my iPhone 4S running iOS 5.0.1 and in Simulator on iOS 5.

I've read that hard resets work (2359739) which seems insane, but I went ahead and tried it in Simulator (iOS Simulator => Reset Content and Settings...) to no avail.

Only thing I can think of is that maybe the iTunes sandbox servers are being wonky...


回答1:


This error can also be caused by trying to use the incorrect iTunes Connect test account. If you attempt to use a test account for another team than the one the app you are testing is registered to, it will cause the same error with no more specific message.




回答2:


Thanks to @user1120741 and @Let's Spot it for verifying this was an Apple issue and posting when it was patched up.

Because Apple does not provide us with an easy means to see system issues like this, developers are left second-guessing fully functioning code.

The Moral: Check Twitter, SO and other sites when you have issues like this. If you're sure you have functioning code, you've nuked Simulator, and it still doesn't work, inform others of your issue (Twitter, SO, etc) and simply wait a few hours.




回答3:


This kind of error (Unknown error or error = 0) is caused by various kind of reasons with two main categories. One is the test user account problems (not the same country, inactive, somehow blocked by Apple etc.) the other is the

payment.productIdentifier 

when you give a incorrect one because of typo or any other reason.




回答4:


I would like to add that you will also receive "failed" with an error code of 0 (zero) if you are attempting to make an In-App purchase from a simulator. In-App purchases can only be successfully tested from a device.



来源:https://stackoverflow.com/questions/8665299/in-app-purchase-error-code-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!