sandbox leaderboard empty
Asked Answered
O

5

7

I'm trying to make a Game Center leaderboard for my app. I've been following the steps from Apple and following the sample code from GKTapper, but I can't get any scores to show in Game Center. I've set up the leaderboard in iTunes Connect. Here's the code that reports the score:

- (void) reportScore: (int64_t) score forCategory: (NSString *) category {
    GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];
    scoreReporter.value = score;

    [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
        if (error != nil)
        {
            UIAlertView* alert= [[[UIAlertView alloc] initWithTitle: @"Score Report Failed!" message: [NSString stringWithFormat: @"Reason: %@", [error localizedDescription]] delegate: self cancelButtonTitle: @"Try Again..." otherButtonTitles: NULL] autorelease];
            [alert show];
        }
    }];
}

The code seems to run fine. The alert is never shown. But, when I go into Game Center, the leaderboard is blank. I'm running Xcode 4.2 and iOS 5. Any ideas?

Overzealous answered 17/6, 2011 at 23:45 Comment(0)
H
3

Whatever's been told is completely true :

  • you need an int_64t score;
  • you need all things set up on iTunesConnect;
  • you need to use a sandbox account.

What I have just found out is that there's no such thing in iTunesConnect as the Category. On the other hand, you're supposed to init your GKScore with the leaderboard category.

From what i've seen over the forums, about 2/3 of the people get it right.

In iTunesConnect, when you configure a leaderboard, you set :

  • its reference (which i long thought was the category);
  • its ID (which turns out to be the actual category).

I was trying to post score using the reference instead of the ID.

Two things :

  • first, i had no error from the program (which, in some way, is acceptable);
  • second, once i got it right, i notice that, whereas many people claim the opposite, there's no need for more than one sandbox account to display the score.
Hetaerism answered 14/9, 2012 at 15:40 Comment(0)
M
2

Setting the category explicitly again after the init fixed it for me.

Scoreobject.category = category

Also to show the right leaderboard I set the category there aswell.

leaderboardobject.category = @"mycategory";
Metabolism answered 13/4, 2012 at 18:55 Comment(0)
G
0

1) Please check if you have spelled the category correctly. Surprisingly, I was not getting an error even when I had my category misspelled. Correcting the typo fixed the issue for me.

2) Please check if you are setting the right Leaderboard before presenting the GKLeaderboardViewController? Set it correctly as below:

GKLeaderboardViewController *leaderboardViewController = [[[GKLeaderboardViewController alloc] init] autorelease];
leaderboardViewController.category = @"yourcategoryname";
[youviewcontroller presentModalViewController:leaderboardViewController animated: YES];
Gilroy answered 4/5, 2012 at 16:6 Comment(0)
J
0

Two verified GameCenter users must have reported scores to a leaderboard before any scores show up in the leaderboard.

If you've only got one user in your Sandbox, create another and report a score.

If it's still not working, make sure that you verified the email address of both users.

Jerusalem answered 8/5, 2012 at 18:27 Comment(0)
C
-1

The documentation for reportScoreWithCompletionHandler says :

"Your application should keep a strong reference to the score object until the reporting task is complete."

You are autoreleasing. Since the task will complete later, the object is probably deleted before the operation is executed.

Cuthburt answered 31/12, 2011 at 3:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.