Hyperbole Hyperbole - 1 year ago 210
iOS Question

Undocumented NSURLErrorDomain error codes (-1001, -1003 and -1004) using StoreKit

I'm writing StoreKit-related code, and I'm getting some rather troubling error codes when I try to add a purchase to the queue.

So far, I've experienced error codes -1003 and -1004 and I can't find anything about those codes on the internet.

Running a product request returns valid product numbers, so I don't know why calls to

[[SKPaymentQueue defaultQueue] addPayment:aPayment];
would fail with this undocumented problem.

The same code also works without the errors on one device but not on another.

The questions I have are, as of yet, unanswered:

What do these codes mean?
How can I mitigate this problem?
Why are they happening for purchase attempts and not for product requests?

Troubleshooting I've done includes regenerating a signing certificate and provisioning profile, changing WiFi networks, cleaning and building and reinstalling all related software and components, and none of these things individually or together have helped fix the problem.


Found a discussion about this on the Apple dev forums, but no one from Apple has responded: https://devforums.apple.com/thread/107121?tstart=75 (iOS developer account required to view)


I was hit with error code -1001 today, to add to this list of inexplicable and intermittent problems. Still no accountability from Apple, that I can find.


I have a suspicion that these error codes are randomly generated and really only indicate that the Sandbox is down. Anyone else experience this problem?

Answer Source

All error codes are on "CFNetwork Errors Codes References" on the documentation (link)

A small extraction for CFURL and CFURLConnection Errors:

  kCFURLErrorUnknown   = -998,
  kCFURLErrorCancelled = -999,
  kCFURLErrorBadURL    = -1000,
  kCFURLErrorTimedOut  = -1001,
  kCFURLErrorUnsupportedURL = -1002,
  kCFURLErrorCannotFindHost = -1003,
  kCFURLErrorCannotConnectToHost    = -1004,
  kCFURLErrorNetworkConnectionLost  = -1005,
  kCFURLErrorDNSLookupFailed        = -1006,
  kCFURLErrorHTTPTooManyRedirects   = -1007,
  kCFURLErrorResourceUnavailable    = -1008,
  kCFURLErrorNotConnectedToInternet = -1009,
  kCFURLErrorRedirectToNonExistentLocation = -1010,
  kCFURLErrorBadServerResponse             = -1011,
  kCFURLErrorUserCancelledAuthentication   = -1012,
  kCFURLErrorUserAuthenticationRequired    = -1013,
  kCFURLErrorZeroByteResource        = -1014,
  kCFURLErrorCannotDecodeRawData     = -1015,
  kCFURLErrorCannotDecodeContentData = -1016,
  kCFURLErrorCannotParseResponse     = -1017,
  kCFURLErrorInternationalRoamingOff = -1018,
  kCFURLErrorCallIsActive               = -1019,
  kCFURLErrorDataNotAllowed             = -1020,
  kCFURLErrorRequestBodyStreamExhausted = -1021,
  kCFURLErrorFileDoesNotExist           = -1100,
  kCFURLErrorFileIsDirectory            = -1101,
  kCFURLErrorNoPermissionsToReadFile    = -1102,
  kCFURLErrorDataLengthExceedsMaximum   = -1103,