Question

I have created a single leaderboard for my app. It shows up in game center, however the score is never submitted.

I submitted a test score with this code:

GKScore* gkScore;

// Set the score value
gkScore.value = gameTimer;

// Send the score to Game Center
[gkScore reportScoreWithCompletionHandler:^(NSError* error) {}];
Was it helpful?

Solution

This is the function that I use to submit scores that works for me

- (void) reportScore: (int64_t) reportScore forLeaderboardID: (NSString*) identifier
{
    GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: identifier];
    scoreReporter.value = reportScore;
    scoreReporter.context = 0;

    NSArray *scores = @[scoreReporter];
    [GKScore reportScores:scores withCompletionHandler:nil];

}

Also, make sure your leaderboard is either live or added to the new version submission. itunesConnect > Your App > View Details of New Version > Game Center add the new leaderboard if it hasn't been added already.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top