Search code examples
iphoneiosgame-centerleaderboard

Gamer Center leaderboard shows no scores, and each user only has access to their own score


I'm trying to make a leaderboard in my game with Game Center. I post the high score like so:

GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"grp.high_scores"] autorelease];
    myScoreValue.value = self.game.scoreMeter.score;

    NSLog(@"Attemping to submit score: %@", myScoreValue);

    [myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
        if(error != nil){
            NSLog(@"Score Submission Failed");
        } else {
            NSLog(@"Score Submitted");
            id appDelegate = [[UIApplication sharedApplication] delegate];
            [appDelegate displayLeaderBoard:nil];
        }

    }];

I see "Score Submitted" as expecting, and it brings up the Game Center leaderboard view, but it just reads "No Scores"

I know other people have said you need at least two accounts, but I've tried with three already.

For each account, the game shows up for them in the Game Center App, and when I query for the top ten scores:

- (void) retrieveTopTenScores
{
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
    if (leaderboardRequest != nil)
    {
        leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
        leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
        leaderboardRequest.range = NSMakeRange(1,10);
        [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
            if (error != nil)
            {
                NSLog(@"Error grabbing top ten: %@", error);
            }
            if (scores != nil)
            {
                NSLog(@"Top ten scores: %@", scores);
            }
        }];
    }
}

each user only sees their own score.

So why is the leaderboard empty, and why is each user only seeing their own score?


Solution

  • Well, it turns out you need to be signed in to game center with a developer sandbox account for it to work correctly