Skip to content

Default Leaderboard

Stanislav Osipov edited this page Apr 18, 2020 · 2 revisions

When you define your leaderboards in iTunes Connect, one leaderboard is designated as the default leaderboard. When your game performs a leaderboard task without specifying a leaderboard, the default leaderboard is automatically chosen.

The initial value for the default leaderboard is the value you assign in iTunes Connect. However, as a player plays your game, you can set a different default leaderboard for that player. You can change the default leaderboard automatically when reporting a new score or you can change the default leaderboard independent of score reporting. For example, if your game has multiple sequential levels and a leaderboard for each level, you can change the default leaderboard each time the local player advances to a higher level. That way, future scores (or displayed leaderboards) automatically show the best level the player has played.

Loading the default leaderboard for the local player:

using SA.iOS.GameKit
...

ISN_GKLocalPlayer.LocalPlayer.LoadDefaultLeaderboardIdentifier((result) =>
{
    if(result.IsSucceeded)
        Debug.Log(result.CategoryID);
    else
        Debug.LogError(result.Error.FullMessage);
});

This method loads the default leaderboard set in App Store Connect. Use this method to retrieve the default leaderboard. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

Set Default Leaderboard

Use SetDefaultLeaderboardIdentifier to set the default leaderboard for the current game. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. The completion handler is always called on the main thread.

The default leaderboard is configured in App Store Connect as part of configuring your game’s leaderboards. All players normally start with this leaderboard as the default leaderboard. Calling this method changes the default leaderboard only for the local player.

About

Foundation

AV Foundation

App Tracking Transparency

Game Kit

Store Kit

UI Kit

Social

Replay Kit

Contacts

AVKit

Photos

App Delegate

User Notifications

MediaPlayer

Core Location

AdSupport

EventKit

CloudKit

Authentication Services

XCode

Knowledge Base

Clone this wiki locally