I am receiving the following error in a callback to loadScoresWithCompletionHandler:
Error Domain=NSURLErrorDomain Code=-1005
"The operation couldn’t be completed. (NSURLErrorDomain error -1005.)"
Other calls to Game Center both before and afterwards succeed. (They operate on various threads). If have initialized the leaderboard request as follows:
GKLeaderboard *leaderboard = [[GKLeaderboard alloc] init];
leaderboard.identifier = leaderboardIdentifier; // valid identifier
leaderboard.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
leaderboard.range = NSMakeRange(1, 100); // max. allowed range.
leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
[leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
// ...
}];
What is going on here and how can I overcome this problem?
The calls to loadScoresWithCompletionHandler: are made from an operation on an NSOperationQueue whose task it is to issue requests for scores (I am interested in each localPlayerScore) to several leaderboards and wait for all responses. The first response already carries the error.
UPDATE -1005 denotes kCFURLErrorNetworkConnectionLost; the underlying cause is still unclear.
UPDATE If I send only a single request (instead of as so far typically 6 in parallel) I receive error NSURLErrorDomain -1001, which denotes kCFURLErrorTimedOut, or GKErrorDomain 3 ...
For some reason this alternative call does not lead to errors:
GKLeaderboard *leaderboard =
[[GKLeaderboard alloc] initWithPlayers:#[ GKLocalPlayer.localPlayer ]];
leaderboard.identifier = leaderboardIdentifier;
leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
[leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
// ...
}];
Problem solved.
Related
When I'm trying to perform request for inserting of a broadcast I receive error:
Error Domain=com.google.GTLRErrorObjectDomain Code=403 "The user is blocked from live streaming."
UserInfo={GTLRStructuredError=GTLRErrorObject 0x28027ad30: {code:403
errors:[1] message:"The user is blocked from live streaming."},
NSLocalizedDescription=The user is blocked from live streaming.}
I have started receiving this error today. Before, everything has been working fine. I have tested on several accounts and had not any luck.
Code:
GTLRYouTube_LiveBroadcastSnippet *broadcastSnippet= [[GTLRYouTube_LiveBroadcastSnippet alloc] init];
[broadcastSnippet setTitle:title];
[broadcastSnippet setScheduledStartTime:[GTLRDateTime dateTimeWithDate:self.beginOfStream]]; // current date + 1 minute.
[broadcastSnippet setScheduledEndTime:[GTLRDateTime dateTimeWithDate:[NSDate dateWithTimeIntervalSinceNow:80000]]];
GTLRYouTube_LiveBroadcastStatus *status = [[GTLRYouTube_LiveBroadcastStatus alloc] init];
[status setPrivacyStatus:[StreamSettings youtubeStringForPrivacyStatus:[privacyStatus intValue]]];
GTLRYouTube_LiveBroadcastContentDetails *details = [self streamDetailsWith:latency];
GTLRYouTube_LiveBroadcast *broadcast = [[GTLRYouTube_LiveBroadcast alloc] init];
[broadcast setKind:#"youtube#liveBroadcast"];
[broadcast setSnippet:broadcastSnippet];
[broadcast setStatus:status];
GTLRYouTubeQuery_LiveBroadcastsInsert *query = [GTLRYouTubeQuery_LiveBroadcastsInsert queryWithObject:broadcast
part:#"id, snippet, contentDetails,status"];
GTLRYouTubeService *service = self.youTubeService;
__strong id <YouTubeHelperDelegate> strongDelegate = self.delegate;
[service executeQuery:query completionHandler:^(GTLRServiceTicket *ticket,
GTLRYouTube_LiveBroadcast *returnedBrocast,
NSError *error) {
if (error) {
NSLog(#"%#", error); //Here is place I got an error
}
}];
If the logged in user does not have more than 1000 subscribers he can't go live using a mobile app, as mentioned in link:
https://support.google.com/youtube/answer/2853834?hl=en
I'm trying to fetch some records from Cloud Server w/ the code snippet below. It returns records w/o any error in most times:
CKQuery * query = [[CKQuery alloc] initWithRecordType:#"MyTable"
predicate:[NSPredicate predicateWithFormat:#"accountID = 1"]];
CKQueryOperation * recordFetchOperation = [[CKQueryOperation alloc] initWithQuery:query];
recordFetchOperation.database = [[CKContainer defaultContainer] privateCloudDatabase];
recordFetchOperation.recordFetchedBlock = ^(CKRecord *record) {
// get records succeed some times
};
recordFetchOperation.queryCompletionBlock = ^(CKQueryCursor *cursor, NSError *operationError) {
if (operationError) [self _handleError:operationError];
};
... // some other operations
NSOperationQueue * queue = [[NSOperationQueue alloc] init];
[queue addOperations:#[recordFetchOperation, ...]
waitUntilFinished:NO];
But sometimes, it returns error:
{
NSDebugDescription = "CKInternalErrorDomain: 1009";
NSLocalizedDescription = "No operations present in request";
NSUnderlyingError = "Error Domain=CKInternalErrorDomain Code=1009 \"No operations present in request\" UserInfo={NSLocalizedDescription=No operations present in request}";
}
I've checked the error code, it's CKErrorInvalidArguments, which as doc said
Bad client request (bad record graph, malformed predicate)
I've no idea how this error comes and how to handle this error, unlike CKErrorNetworkUnavailable error, it does not have CKErrorRetryAfterKey value in error.userInfo for me to send the request after a time interval.
Btw, when I got this error, all my operations will have this error w/o any record returned.
I have an app with data fed from an AFNetworking request with basic auth. I have a refresh button to perform the same function used to initially feed the data. This all works, but after a couple minutes it doesn't.
My code:
- (void) refreshData
{
// Show loading
NSLog(#"Refreshing...");
[LoadingView initInView:self.view];
// Get session data for auth key
SessionHelper *session = [SessionHelper sharedInstance];
// Setup request
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager setRequestSerializer:[AFHTTPRequestSerializer serializer]];
[manager.requestSerializer clearAuthorizationHeader];
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:session.authKey password:#""];
NSString *url = #"https://myurl.com/getdata";
[manager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.data = [[NSMutableArray alloc] init];
[self.data addObjectsFromArray:responseObject];
[self.tableView reloadData];
[LoadingView remove];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(#"Error: %#", [error description]);
[operation cancel];
}];
}
Works repeatedly fine at first, but after a few minutes it hangs with the loading screen (from LoadingView) and the error:
Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation
couldn’t be completed. (NSURLErrorDomain error -1012.)"
UserInfo=0x8a5ed20 {NSErrorFailingURLKey=https://myurl.com/getdata,
NSErrorFailingURLStringKey=https://myurl.com/getdata}
I thought maybe I needed to do clearAuthorizationHeader or something, but no go. Any ideas? Thanks!
Update: Logging operation.response.statusCode in the error message
gives me 0.
Update 2: Using AFNetworkActivityLogger gives me this after it starts failing:
2014-02-26 13:23:02.206 MyApp iPad[4087:60b]
GET 'https://myurl.com/getdata' 2014-02-26 13:23:02.646 MyApp
iPad[4087:60b] [Error] GET '(null)' (0) [0.4332 s]: Error
Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be
completed. (NSURLErrorDomain error -1012.)" UserInfo=0x17d9a990
{NSErrorFailingURLKey=https://myurl.com/getdata,
NSErrorFailingURLStringKey=https://myurl.com/getdata} 2014-02-26
13:23:02.648 MyApp iPad[4087:60b] Error: Error Domain=NSURLErrorDomain
Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain
error -1012.)" UserInfo=0x17d9a990
{NSErrorFailingURLKey=https://myurl.com/getdata,
NSErrorFailingURLStringKey=https://myurl.com/getdata}, Status Code: 0
Seems the URL is being sent as (null)...
Turns out, even though the GoDaddy certificate I'm using looks to be valid and supported by iOS 7 according to http://support.apple.com/kb/HT5012, adding this bit solves the problem. Seems to kind of defeat the purpose, but it works. I won't accept this answer yet in case someone can give some insight / something more helpful.
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
securityPolicy.allowInvalidCertificates = YES;
manager.securityPolicy = securityPolicy;
I'm trying to fetch the default leaderboard scores from Game Center (Sandbox mode) using the code provided in apple docs. It works fine on all iOS versions except iOS 7. I've added the identifier property as required for iOS 7 but it returns this error:
Error Domain=GKErrorDomain Code=17 "The requested operations could not be completed because one or more parameters are invalid." UserInfo=0x16c5cdf0 {GKServerStatusCode=5053, NSUnderlyingError=0x16cb68a0 "The operation couldn’t be completed. status = 5053, asking for legacy aggregate leaderboard on a game with no legacy aggregate leaderboard", NSLocalizedDescription=The requested operations could not be completed because one or more parameters are invalid.
The code I'm using to retrieve scores:
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil)
{
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardRequest.identifier = #"LEADERBOARD_NAME";
leaderboardRequest.range = NSMakeRange(1,100);
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil)
{
// Handle the error.
NSLog(#"%#",error.description);
}
if (scores != nil)
{
// Process the score information.
}
}];
}
Thanks in advance!
I had a function to load the top score from the leaderboard for my iOS game, and it worked in iOS 6 but it no longer works in iOS 7. The function I used is as follows:
- (void) retrieveGlobalHighScore {
if(userAuthenticated == true) {
//NSLog(#"Attempting to retrieve global high score...");
GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
if (leaderboardRequest != nil) {
leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboardRequest.range = NSMakeRange(1,1);
[leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
if (error != nil) {
// handle the error. if (scores != nil)
NSLog(#"ERROR: Issue loading global high score.");
NSLog(#"Unresolved error %#", error);
}
if (scores != nil){
// process the score information.
globalHighScoreReturn = ((GKScore*)[scores objectAtIndex:0]).value;
}
}];
}
} else {
//NSLog(#"User is not authenticated. Global high score not loaded.");
}
}
I now get the following error and cannot figure out how to fix it:
Error Domain=GKErrorDomain Code=17
"The requested operations could not be completed because one or more parameters are invalid."
UserInfo=0xf539250 {GKServerStatusCode=5053, NSUnderlyingError=0xf538670 "The operation couldn’t be completed.
status = 5053, asking for legacy aggregate leaderboard on a game with no legacy aggregate leaderboard", NSLocalizedDescription=The requested operations could not be completed because one or more parameters are invalid.}
Any help would be greatly appreciated!
This is what I had to add to fix the problem (iOS 7):
leaderboardRequest.identifier = #"my_leaderboardID";
I found the issue. In iOS 6, setting leaderboardRequest.category was not needed and the default leaderboard (I am only using 1) was automatically selected. In iOS 7, the category had to be specified. Specifying the identifier worked as well, however I am supporting both iOS 6 and 7.