When using MKStoreKit or any other equivalent framework or regular In App Purchases’ StoreKit.framework, If you are getting a problem like this,
Cannot connect to iTunes Store Code: Error code: 0
Error code 0 is SKErrorUnknown. It probably means connection couldn’t be established from your device to Apple.
The number one reason for this is, you are using a jailbroken iPad that updated the hosts file to block traffic to gs.apple.com
The second reason which I found today is that you are making the product purchase call on a delegate callback instead of the main thread.
A common example of this is showing the list of products on a UITableView and making the purchase on the UITableViewDelegate. Or showing an additional UIAlertView prompt and making the real purchase on the delegate call back.
StoreKit.framework internally using NSURLConnection and to quote from Apple Documentation
By default, for the connection to work correctly, the calling thread’s run loop must be operating in the default run loop mode. See
scheduleInRunLoop:forMode:to change the run loop and mode.
You don’t have control over StoreKit code to change the run loop. As such, you should ensure that, calls to add your product to the queue are done on the main thread.
I’ll fix this in MKStoreKit and commit it to Github. Watch the repo or this blog post for updates.
Follow me on Twitter