How to show leaderboards in GameCenter on tvOS?

I'm using Xamarin to write my tvOS apps. The tools are currently in a state where not everything is supported. One of these things is the support for setting up the launch image, setting the app icons and to define the leaderbords supported by GameCenter.


I successfully created my icons and launch image in an Xcode project (http://stackoverflow.com/questions/32770956/how-to-open-gamecenter-in-tvos) and use them in Xamarin Studio. However I failed for setting up my leaderboard for GameCenter.


  • The leaderboard is already used in the iOS version of my game, so the setup in ITC is correct
  • tvOS won't let me configure `GKGameCenterViewController` to show a specific leaderboard, the `LeaderboardIdentifier` property is simply missing (just like the `ViewState`):
  • From another thread here on the forums I learned that I have to create an asset and set the leaderboard identifier in there. That's what I did in Xcode. I also incuded the required artwork poster.
  • I inspected the resulting IPA from Xcode and found a GKGameCenterContent.plist file in there which seems to contain all the relevant information (see below).
  • I added this plist to my Xamarin project, hoping that this would be enough for tvOS to pick up my leaderboard config, but it's not. If I present the game center controller it will only show my achievements.


Can anybody tell me, if this plist is maybe referenced from somewhere else? Or should tvOS simply check if the bundle contains a plist file with the name GKGameCenterContent.plist and use it?



    <?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>

Any luck finding a solution yet @Krumelur?


Same issue: Calling code:


- (void)presentLeaderboardsOnViewController:(UIViewController *)viewController withLeaderboard:(NSString *)leaderboard {
    GKGameCenterViewController *leaderboardViewController = [[GKGameCenterViewController alloc] init];
    leaderboardViewController.gameCenterDelegate = self;
    [viewController presentViewController:leaderboardViewController animated:YES completion:nil];
}


(Shows Achievements only, not the leaderboard).


According to the Apple Docs (tvOS)

https://developer.apple.com/library/tvos/documentation/GameKit/Reference/GKGameCenterViewController_Ref/index.html


The following should work: (according to the documentation)

- (void) showLeaderboard: (NSString*) leaderboardID 
{ 
  GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init]; 
  if (gameCenterController != nil) 
  { 
  gameCenterController.gameCenterDelegate = self; 
  gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards; 
  gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeToday; 
  gameCenterController.leaderboardCategory = leaderboardID; 
  [self presentViewController: gameCenterController animated: YES completion:nil]; 
  } 
}

However those critical commands are not available in tvOS:

gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;  // 'viewState' is unavailable: not available on tvOS
        gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeToday; // 'leaderboardTimeScope' is unavailable: not available on tvOS
        gameCenterController.leaderboardCategory = leaderboardID;   // 'leaderboardCategory' is unavailable: not available on tvOS



Problem is that these are defined as TVOS_UNAVAILABLE here: GKGameCenterViewController.h


@interface GKGameCenterViewController (Leaderboards)
@property (nonatomic, assign)   GKLeaderboardTimeScope leaderboardTimeScope NS_AVAILABLE(10_8, 4_1) __TVOS_UNAVAILABLE;
@property (nonatomic, nullable, retain)   NSString *leaderboardIdentifier NS_AVAILABLE(10_10, 7_0) __TVOS_UNAVAILABLE;
@property (nonatomic, nullable, retain)   NSString *leaderboardCategory    NS_DEPRECATED(10_8, 10_10, 4_1, 7_0, "GKGameCenterViewController's leaderboardCategory property is deprecated. Use leaderboardIdentifier instead.") __TVOS_UNAVAILABLE;
@end

Solution:


The issue is not the API however, the tvOS Apple documentation (needs to be updated!!?)


To get the Leaderboards to show up:

1. Achievements and Leaderboards are merged into a single GameCenter view, with the Leaderboards shown above the achievements.

2. For tvOS adding the Leaderboards to the GameViewController is all about the Image Assets.

3. You must add a "+ -> GameCenter -> New Apple TV Leaderboard (or Set)." to your Image Asset.

4. You must set the "Identifier" for this Leaderboard asset to exactly what your identifier is for each of your leaderboards. Example:

grp.GameCenterManager.PlayerScores

5. You must have the image sizes 659 × 371 for the Leaderboard Images.

Thanks for posting this.


For those who are confused about the "Identifier", it is not the name of the Visual Asset in the folder but rather a property which can be set on it by using that pop-out menu accessible with the rightmost of the three submenu buttons on the top-right of Xcode.

How to show leaderboards in GameCenter on tvOS?
 
 
Q