문제

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) {}];
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top