I implemented GKAchievement in GKTurnBasedMatch, and it worked initially. Now I get this error reporting achievements for another player. Interestingly, the same code awarding the local player
Terminating app due to uncaught exception 'GKInvalidArgumentException', reason: 'A GKAchievement can only be submitted for another player when ending a turn-based match.'
This is the code I use to post GKAchievement
GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier:identifier forPlayer:playerID];
if(achievement) {
achievement.percentComplete = percent;
achievement.showsCompletionBanner = YES;
[GKAchievement reportAchievements:@[achievement]
withCompletionHandler:^(NSError *error) {
if(error) {
NSLog(@"Unable to report achievement: %@", error);
}
completion(nil);
}];
}
And this is the code to complete GKTurnBasedMatch
[self.gkMatch endMatchInTurnWithMatchData:archivedData
completionHandler:^(NSError *error) {
if(!error) {
NSLog(@"Awarding Achievement to %@", [self getWinner].log);
NSString *winnerPlayerId = [self getWinner].playerId;
[self awardAchievement:@"someAchievement" to:winnerPlayerId percentCompleted:100.0 completion:^(NSError *error1) {
completion(error1);
}];
} else {
NSLog(@"endMatchInTurnWithMatchData %@", error);
}
}];
Help me with this. Thank.
source
share