Upon start up, I am trying to clear all the matches on the game centre servers between my devices programatically by calling this method on each device:
/**
* called to authenticate the players game centre id
*/
- (void)authenticateLocalUser
{
if (!self.gameCentreAvailable) return;
NSLog(@"Authenticating Local User.");
if ([GKLocalPlayer localPlayer].authenticated == NO)
{
[[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController* viewcontroller, NSError *error)
{
NSLog(@"Inside Authentication Handler.");
// if there was no error, and we got a valid view controller to display
if (!error && viewcontroller)
{
// get a handle to the app delegate
AppDelegate *delegate = [UIApplication sharedApplication].delegate;
// use the view controller in the app delegate to present the authentication view controller
[delegate.viewController presentViewController:viewcontroller animated:YES completion:
^{
// once the view controller has been displayed, register the change in authentication
[self authenticationChanged];
}];
// set this class as the event handler delegate
GKTurnBasedEventHandler *event = [GKTurnBasedEventHandler sharedTurnBasedEventHandler];
event.delegate = self;
}
// load all of the matches the player is currently a part of
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error)
{
NSLog(@"Error loading matches: %@", error);
// for each match
for (GKTurnBasedMatch *match in matches)
{
// log the id of the match
NSLog(@"ID of match we are removing: %@", match.matchID);
// and then remove it
[match removeWithCompletionHandler:^(NSError *error)
{
NSLog(@"Error removing match: %@", error);
}];
}
}];
}];
}
else
NSLog(@"Already Authenticated.");
}
However, the method does not work, and instead I am greeted with this error in the console:
2012-11-05 08:32:39.699 Spinning Yarn[6266:907] Error removing match: Error Domain=GKErrorDomain Code=17 "The requested operations could not be completed because one or more parameters are invalid." UserInfo=0x1e5b2140 {NSLocalizedDescription=The requested operations could not be completed because one or more parameters are invalid.}
The only error that is happening is inside of the removeWithCompletionHandler: Everything else is fine, and there are no errors.
Any help would be awesome.