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.
–
Mugunth
Follow me on Twitter
Related posts:
- MKStoreKit 4.0 – Supporting Auto Renewable Subscriptions MKStoreKit started off in a pet project a couple of...
- iOS Code: TweetBot like AlertPanels TweetBot is sexy, no one can deny it. One of...
- iOS Code: MKiCloudSync – Sync your NSUserDefaults to iCloud with a single line of code Just wrote this class, MKiCloudSync (100 lines of code) that...
- iOS5: Migrating your code to NSJSONSerialization using the Adapter Design Pattern In iOS 5, Apple introduced NSJSONSerialization, for parsing JSON strings....
-
Jesua
-
dave
-
Jesua
-
Second_gear
-
Second_gear
