3

I think I followed all the required steps to support leaderboards in my game (and they work just fine on iOS), however on tvOS it is not possible to configure the GKGameCenterViewController to show a specific leaderboard, the LeaderboardIdentifier property is simply missing (just like the ViewState):

var leaderboardController = new GKGameCenterViewController ();

// Unavailable on tvOS
/*
leaderboardController.ViewState = GKGameCenterViewControllerState.Default;
leaderboardController.LeaderboardIdentifier = "myLeaderboardId";
*/ 

leaderboardController.Finished += (sender, e) =>
{
  leaderboardController.DismissViewController (true, null);
}

PresentViewController (leaderboardController, true, null);

Instead of using these properties, I followed the instructions here. I notice that this will generate a GKGameCenterContent.plist file in the final app bundle. I double checked the content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>GKLeaderboards</key>
    <array>
        <dict>
            <key>identifier</key>
            <string>myLeaderboardId</string>
            <key>onDemandResourcesTag</key>
            <string>com.apple.gamecenter.Leaderboard</string>
            <key>posterImageName</key>
            <string>Leaderboard/Poster</string>
        </dict>
    </array>
</dict>
</plist>

This looks absolutely correct, also the images are of course in the bundle. Still, using the code above to show the game center controller will only give me the achievements screen and nothing else.

Community
  • 1
  • 1
Krumelur
  • 32,180
  • 27
  • 124
  • 263

1 Answers1

2

You have to add a leaderboard to Assets.xassets. There you can enter the identifier:

enter image description here

The code to show the leaderboard:

@IBAction func openLeaderboard(sender: AnyObject) {

    let gcViewController = GKGameCenterViewController()
    gcViewController.gameCenterDelegate = self
    self.presentViewController(gcViewController, animated: true, completion: nil)
}
Stefan
  • 5,203
  • 8
  • 27
  • 51
  • OK. I haven't followed the link. Just saw, that this was my question – Stefan Dec 05 '15 at 22:27
  • For me it worked fine. I guess you have successfully created the leaderboard in iTunesConnect and you are using the same leaderboard in your iOS and AppleTV game? – Stefan Dec 05 '15 at 22:29
  • Yeah...the iOS version works fine. The problem is: I have to export the leaderboard config to include it into Xamarin Stuidio. I presume I'm missing one step...current XS does not support tvOS leaderboards. – Krumelur Dec 05 '15 at 22:47
  • I'm just creating my leaderboard for my second AppleTV game. If it works I'll let you know what I did different. Could take till tomorrow. – Stefan Dec 05 '15 at 22:50