GameCenter not updating leaderboard

允我心安 提交于 2019-12-21 23:54:40

问题


Using the sandboxed Gamecenter.

No matter what I do the scores never appear in a leaderboard.

I am using the following code:

- (void)scoreReported: (NSError*) error {
    NSLog(@"%@",[error localizedDescription]);
}

- (void)submitScore{

    if(self.currentScore > 0)
    {
        NSLog(@"Score: %lli submitted to leaderboard %@", self.currentScore, self.currentLeaderBoard);
        [gameCenterManager reportScore: self.currentScore forCategory: self.currentLeaderBoard];
    }
}

And scoreReported doesnt produce an error, yet the score doesnt appear in the leaderboard. I know the category is correct as I use currentLeaderBoard in:

- (void)showLeaderboard {
    NSLog(@"leaderboard = %@", self.currentLeaderBoard);
    GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
    if (leaderboardController != NULL)
    {
        leaderboardController.category = self.currentLeaderBoard;
        //leaderboardController.category = nil;
        leaderboardController.timeScope = GKLeaderboardTimeScopeWeek;
        leaderboardController.leaderboardDelegate = self;
        [self presentModalViewController: leaderboardController animated: YES];
    }
}

I have tried the usual 2 different sandbox GC accounts to get the leaderboard working Even tried 4 different GC accounts each logging in on both the simulator (iOS 6.1) and device (iOS 6.0.1) Yet still no joy

any suggestions - or is it just that the sandboxed gamecenter is far too buggy!!! (I would raise a bug about sandbox but the apple bug reporting form has a bug in it so that doesnt work either)


回答1:


Score reporting to Game Center works almost immediately for me, even in sandbox mode.

Here are the few things you can try

  1. Make sure the the Leaderboard identifiers are correct when reporting scores (Should exactly match with "Leaderboard ID"s in iTunesConnect)
  2. Try Deleting the test data under "Manage Game Center" section of iTunesConnect
  3. Delete the application, launch "Game Center" application in your device and goto "Games" tab and remove your app. Reinstall the app and try reporting the score again.
  4. Make sure [gkScore reportScoreWithCompletionHandler:^(NSError *error) doesn't return any error



回答2:


For those who want to know this what I changed my submitScore method to:

 - (void)submitScore {
    GKScore * GCscore = [[GKScore alloc] initWithCategory:self.currentLeaderBoard];
    GCscore.value = [[NSUserDefaults standardUserDefaults] integerForKey:@"NEWSCORE"];
    [GCscore reportScoreWithCompletionHandler:^(NSError *error) {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            if (error == NULL) {
                NSLog(@"Score Sent");
            } else {
                NSLog(@"Score Failed, %@",[error localizedDescription]);
            }
        });
    }];
  }

and it worked



来源:https://stackoverflow.com/questions/16978447/gamecenter-not-updating-leaderboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!