Question

I'm trying to create a lib that will verify StoreKit receipts connecting straight to Apples servers, without a 3rd party server. This is possible since Apple recommends you first verify against the production server http://buy.itunes.apple.com/verifyReceipt and if that fails with code 21007, try the sandbox server https://sandbox.itunes.apple.com/verifyReceipt.

However, I'm stuck at receiving the error "Could not connect to the server." for the production server, or "The network connection was lost." from the sandbox server.

If i send the same exact post data to either of the URLs using Hurl.it, i get the correct responses.

Am I doing something wrong, or is this simply blocked by Apple to force you to use a middle man server to verify receipts? And if so, why?

Thanks

Maciej

Was it helpful?

Solution

Forgot about these two lines. All working now.

[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:[NSString stringWithFormat:@"%d", [[jsonString dataUsingEncoding:NSUTF8StringEncoding] length]] forHTTPHeaderField:@"Content-Length"];

OTHER TIPS

I had a similar problem testing on the simulator, and it turned out to be this. NSURLConnection GET request returns -1005, "the network connection was lost"

My Mac had a working internet connection the simulator did not. Restarting the simulator fixed the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top