【问题标题】:GameCenter not updating leaderboardGameCenter 不更新排行榜
【发布时间】:2013-06-03 10:14:48
【问题描述】:

使用沙盒游戏中心。

无论我做什么,分数都不会出现在排行榜中。

我正在使用以下代码:

- (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];
    }
}

并且 scoreReported 不会产生错误,但分数不会出现在排行榜中。我知道类别是正确的,因为我在以下位置使用 currentLeaderBoard:

- (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];
    }
}

我已经尝试了通常的方法 2 个不同的沙盒 GC 帐户,让排行榜工作 甚至尝试了 4 个不同的 GC 帐户,每个帐户都在模拟器(iOS 6.1)和设备(iOS 6.0.1)上登录 还是不开心

任何建议 - 或者仅仅是沙盒游戏中心的问题太多了!!! (我会提出一个关于沙盒的错误,但苹果错误报告表单中有一个错误,因此也不起作用)

【问题讨论】:

  • 您在将分数发布到排行榜后等待了多长时间?
  • 从 2 分钟到 16 小时不等

标签: ios game-center leaderboard


【解决方案1】:

我几乎可以立即向 Game Center 报告分数,即使在沙盒模式下也是如此。

以下是您可以尝试的几件事

  1. 在报告分数时确保排行榜标识符正确(应与 iTunesConnect 中的“排行榜 ID”完全匹配)
  2. 尝试在 iTunesConnect 的“管理游戏中心”部分下删除测试数据
  3. 删除应用程序,在您的设备中启动“游戏中心”应用程序并转到“游戏”选项卡并删除您的应用程序。重新安装应用并尝试再次报告分数。
  4. 确保 [gkScore reportScoreWithCompletionHandler:^(NSError *error) 不返回任何错误

【讨论】:

  • 感谢您指出 reportScoreWithCompletionHandler。我更改了 submitScore 方法并且它起作用了
  • 您能准确地说“几乎立即”是什么意思吗? 10秒? 10 分钟?
【解决方案2】:

对于那些想知道这一点的人,我将 submitScore 方法更改为:

 - (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]);
            }
        });
    }];
  }

成功了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 2012-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多