- Home /
GameKit Authenticates but can't post scores to leaderboard
Hi there,
At the end of the level I am trying to post the score, then retrieve the top 10 scores via:
if (CoreXT.IsDevice) { GameKitXT.ReportScore(leaderboardID, Convert.ToInt64(myGUI.text)); //GameKit Reporting RetrieveTopTenScores(); }
I have confirmed that the leaderboardID is correct on iTunes. (I am using the leaderboard ID from iTunes, not the reference name). I have ensured that GameCentre is turned on for the app. In the app I can see local.auth happening correctly and I get a "Welcome Back XXX, Sandbox" Message. I have tried replacing the Convert.ToInt64(myGUI.text) with the int score variable.
Once I look on Ios7 game centre there are no scores associated with the leaderboard. The RetrieveTopTenScores is also not working as there are no scores to retrieve.
Answer by FfZ · Jan 24, 2014 at 08:05 AM
Hi there,
Thank you for the prompt response ;) It appears as if the score is being reported , but there is nothing on game centre (sandbox ?)
Debug:
"Local Player authenticated G:1920xxxxxxx (numeric) "Local player has no photo or error loading photo" "Loaded friends" "Reported Score" "Error retrieving scores: The requested operations could not be completed because one or more of the parameters are invalid"
End of Debug --
void RetrieveTopTenScores() { GKLeaderboard leaderboardRequest = new GKLeaderboard(); if (leaderboardRequest != null) { // configure request leaderboardRequest.playerScope = GKLeaderboardPlayerScope.Global; leaderboardRequest.timeScope = GKLeaderboardTimeScope.AllTime; leaderboardRequest.category = leaderboardID; leaderboardRequest.range = new NSRange(1, 10);
// load scores; it calls delegate back when done
leaderboardRequest.LoadScores(delegate(object[] scores, NSError error) {
if (error != null) {
Log("Error retrieving scores: " + error.LocalizedDescription());
} else if (scores != null) {
// got the scores, but the low-level GKScore only has player ID.
// if you want player display name, you need to combine it with
// the high-level API to load the players
string[] playerIDs = scores.Cast<GKScore>().Select(x => x.playerID).ToArray();
Player.LoadPlayersByIDs(playerIDs, delegate(Player[] players) {
// print localized title of leaderboard
//Log("Top 10 for " + leaderboardRequest.title);
for (int i=0; i<scores.Length; i++) {
GKScore score = scores[i] as GKScore;
Player player = players[i];
myLabel.text = (score.rank + ". " + score.formattedValue + ", " + score.date + ", " + player.displayName);
}
});
}
});
}
}
Hi, it looks like your leaderboardID is not matching. I just tried an incorrect leaderboardID and it also says the score is reported, but it's actually not reported. Retrieving the scores also gives the same error as you did.
Can you make sure the public leaderboardID variable in the scene matches the string in the cs file? Or just to make sure, print it out when you use it.
Hi there, I have called my $$anonymous$$erboard ID "Default". I then have printed it out whenever it is used and it comes back as "com.mdphillips.fb.Default" - $$anonymous$$y bundle ID is "com.mdphillips.fb" and my $$anonymous$$erboard Name is "$$anonymous$$ain" and id is "Default".
If I show the leaderboard in app it comes back with the right app name (mptestapp) but the leaderboard is blank.
Then when I pull the 10 top scores I get the same error as above?
As a test I changed my leaderboard id to "$$anonymous$$ain" , I get the exact same results?
Now I'm really confused.
Hi, the leaderboard ID should match exactly what you put in iTunesConnect for your game. If you put "Default" in iTunesConnect without the bundle ID, you should use just "Default". However, we recommend using the bundle ID as prefix in iTunesConnect. Also, sometimes changes in iTunesConnect don't get reflected immediately -- takes some time ($$anonymous$$utes or even tens of $$anonymous$$utes). Hope this helps.
Answer by u3dxt · Jan 23, 2014 at 04:53 PM
Hi FfZ, can you subscribe to GameKitXT.ScoreReported and ScoreReportedFailed events and print out e.description on error?
You should also call RetrieveTopTenScores() after ReportScore() is completed. ReportScore() is an async method, and dispatches one of the above two events when completed.
Also, the Game Center app may not show your sandbox games. You can however, show it within your game by calling GameKitXT.ShowLeaderboard(leaderboardID).
Answer by FfZ · Jan 24, 2014 at 08:05 AM
Hi there, I have also executed the GameKitXT.ShowLeaderboard(leaderboardID) and it comes back with an empty leaderboard?
thanks,
Mark
Your answer