5

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

Community
  • 1
  • 1
AFR
  • 51
  • 1
  • 2
  • same problem here. both in-app purchase and game center leader board failed. (the leader board is able to show up, but unable to accept any score – OMGPOP Dec 29 '11 at 10:12
  • i guess they need to reset the sandbox environment after the long break – OMGPOP Dec 29 '11 at 10:13
  • I'm getting the same problem. BTW, the storekit doesn't work in the simulator. You need to test on a device, HOWEVER: it is not working on the device either. I've signed out from the store on my phone per instructions [here](http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/StoreKitGuide/DevelopingwithStoreKit/DevelopingwithStoreKit.html#//apple_ref/doc/uid/TP40008267-CH103-SW1) and I still get the error saying it cannot connect to the iTunes store. It is successfully pulling my in-app purchase information though...so I'm starting to wonder if the sandbox is d – dcinzona Dec 29 '11 at 08:32
  • @user1120741 - StoreKit does in fact work in Simulator with iOS 5, now that it is working I tried it again and it worked perfectly in Simulator. – AFR Dec 30 '11 at 02:41

4 Answers4

5

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.

Anthony Mattox
  • 7,048
  • 6
  • 43
  • 59
  • 1
    You're correct. If you have an invalid testing account, nothing will work and there won't be meaningful error messages. Apple believes it's not worth time for them to do something that you should be do. – ABCD Dec 11 '12 at 04:52
  • I'm using the test account I created in App Store Connect and it's still not working. Any ideas? – Supertecnoboff Oct 04 '18 at 09:29
0

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.

BootMaker
  • 1,639
  • 1
  • 22
  • 24
0

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.

Mark A. Durham
  • 844
  • 1
  • 6
  • 18
0

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.

AFR
  • 51
  • 1
  • 2