Reputation: 3947
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.
EDIT:
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)
EDIT:
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.
EDIT:
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?
Upvotes: 114
Views: 145699
Reputation: 1404
The following site is also very useful for finding undocumented or hard to find Apple API error codes:
You can supply just the error code (such as -1001 or kCFURLErrorTimedOut
) or even the Framework or API you are using (such as CFNetwork
, NSURL
or AVAudioSession
) and the site will list all potential errors that match your search, showing the error names, relevant Framework and header files in which the error(s) are defined.
Upvotes: 0
Reputation: 5049
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,
Upvotes: 358
Reputation: 890
I found a new error code which is not documented above: CFNetworkErrorCode -1022
Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
Upvotes: 2
Reputation: 231
see NSURLError.h Define
NSURLErrorUnknown = -1,
NSURLErrorCancelled = -999,
NSURLErrorBadURL = -1000,
NSURLErrorTimedOut = -1001,
NSURLErrorUnsupportedURL = -1002,
NSURLErrorCannotFindHost = -1003,
NSURLErrorCannotConnectToHost = -1004,
NSURLErrorNetworkConnectionLost = -1005,
NSURLErrorDNSLookupFailed = -1006,
NSURLErrorHTTPTooManyRedirects = -1007,
NSURLErrorResourceUnavailable = -1008,
NSURLErrorNotConnectedToInternet = -1009,
NSURLErrorRedirectToNonExistentLocation = -1010,
NSURLErrorBadServerResponse = -1011,
NSURLErrorUserCancelledAuthentication = -1012,
NSURLErrorUserAuthenticationRequired = -1013,
NSURLErrorZeroByteResource = -1014,
NSURLErrorCannotDecodeRawData = -1015,
NSURLErrorCannotDecodeContentData = -1016,
NSURLErrorCannotParseResponse = -1017,
NSURLErrorAppTransportSecurityRequiresSecureConnection NS_ENUM_AVAILABLE(10_11, 9_0) = -1022,
NSURLErrorFileDoesNotExist = -1100,
NSURLErrorFileIsDirectory = -1101,
NSURLErrorNoPermissionsToReadFile = -1102,
NSURLErrorDataLengthExceedsMaximum NS_ENUM_AVAILABLE(10_5, 2_0) = -1103,
// SSL errors
NSURLErrorSecureConnectionFailed = -1200,
NSURLErrorServerCertificateHasBadDate = -1201,
NSURLErrorServerCertificateUntrusted = -1202,
NSURLErrorServerCertificateHasUnknownRoot = -1203,
NSURLErrorServerCertificateNotYetValid = -1204,
NSURLErrorClientCertificateRejected = -1205,
NSURLErrorClientCertificateRequired = -1206,
NSURLErrorCannotLoadFromNetwork = -2000,
// Download and file I/O errors
NSURLErrorCannotCreateFile = -3000,
NSURLErrorCannotOpenFile = -3001,
NSURLErrorCannotCloseFile = -3002,
NSURLErrorCannotWriteToFile = -3003,
NSURLErrorCannotRemoveFile = -3004,
NSURLErrorCannotMoveFile = -3005,
NSURLErrorDownloadDecodingFailedMidStream = -3006,
NSURLErrorDownloadDecodingFailedToComplete =-3007,
NSURLErrorInternationalRoamingOff NS_ENUM_AVAILABLE(10_7, 3_0) = -1018,
NSURLErrorCallIsActive NS_ENUM_AVAILABLE(10_7, 3_0) = -1019,
NSURLErrorDataNotAllowed NS_ENUM_AVAILABLE(10_7, 3_0) = -1020,
NSURLErrorRequestBodyStreamExhausted NS_ENUM_AVAILABLE(10_7, 3_0) = -1021,
NSURLErrorBackgroundSessionRequiresSharedContainer NS_ENUM_AVAILABLE(10_10, 8_0) = -995,
NSURLErrorBackgroundSessionInUseByAnotherProcess NS_ENUM_AVAILABLE(10_10, 8_0) = -996,
NSURLErrorBackgroundSessionWasDisconnected NS_ENUM_AVAILABLE(10_10, 8_0)= -997,
Upvotes: 22
Reputation: 462
I found this page in the documentation which has an objective-c enum for all of the error codes under the NSURLErrorDomain.
Upvotes: 1
Reputation: 952
I use the following method in my project
-(NSArray*)networkErrorCodes
{
static NSArray *codesArray;
if (![codesArray count]){
@synchronized(self){
const int codes[] = {
//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
};
int size = sizeof(codes)/sizeof(int);
NSMutableArray *array = [[NSMutableArray alloc] init];
for (int i=0;i<size;++i){
[array addObject:[NSNumber numberWithInt:codes[i]]];
}
codesArray = [array copy];
}
}
return codesArray;
}
Then I just check the error code and show alert if it is in the list
if ([[self networkErrorCodes] containsObject:[NSNumber
numberWithInt:[error code]]]){
// Fire Alert View Here
}
But as you can see I commented out codes that I think does not fit to my definition of NO INTERNET. E.g the code of -1012 (Authentication fail.) You may edit the list as you like.
In my project I use it at username/password entering from user. And in my view (physical) network connection errors could be the only reason to show alert view in your network based app. In any other case (e.g. incorrect username/password pair) I prefer to do some custom user friendly animation, OR just repeat the failed attempt again without any attention of the user. Especially if the user didn't explicitly initiated a network call.
Regards to martinezdelariva for a link to documentation.
Upvotes: 3
Reputation: 8207
I have similar problems, in my case seem to be related to network connectivity:
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."
Things to check:
Sorry, no ideas how to fix. Just debugging this, trying to find out what the problem is (-1021, -1001, -1009)
Update: Google search was very kind to find this:
Upvotes: 25