API Reference

Core

ISN_GKPlayer


namespace SA.IOSNative.GameKit
...
public class ISN_GKPlayer
{
    /// <summary>
    /// A unique identifier associated with a player.
    /// The player identifier should never be displayed to the player. Use it only as a way to identify a particular player.
    /// Do not make assumptions about the contents of the player identifier string. Its format and length are subject to change.
    /// </summary>
    public string PlayerID {get;}

    /// <summary>
    /// A player’s alias is used when a player is not a friend of the local player. 
    /// Typically, you never display the alias string directly in your user interface. 
    /// Instead use the <see cref="DisplayName"/> property
    /// </summary>
    public string Alias {get;}

    /// <summary>
    /// The display name for a player depends on whether the player is a friend of the local player authenticated on the device. 
    /// If the player is a friend of the local player, then the display name is the actual name of the player. 
    /// If the player is not a friend, then the display name is the player’s alias.
    /// </summary>
    public string DisplayName {get;}
}

ISN_GKLocalPlayer

namespace SA.IOSNative.GameKit
...
public class ISN_GKLocalPlayer : ISN_GKPlayer
{

    /// <summary>
    /// Retrieves the shared instance of the local player.
    /// You never directly create a local player object. Instead, you retrieve the Singleton object by calling this class method.
    /// </summary>
    public static ISN_GKLocalPlayer LocalPlayer {get;} 

    /// <summary>
    /// A Boolean value that indicates whether a local player is currently signed in to Game Center.
    /// </summary>
    public bool Authenticated  {get;} 

    /// <summary>
    /// A Boolean value that declares whether the local player is underage.
    /// Some Game Center features are disabled if the local player is underage. 
    /// Your game can also test this property if it wants to disable some of its own features based on the player’s age.
    /// </summary>
    public bool Underage  {get;} 


    /// <summary>
    /// Authenticate GK Local Player
    /// </summary>
    public static void Authenticate(Action<SA_Result> callback);

    /// <summary>
    /// Generates a signature that allows a third party server to authenticate the local player.
    /// 
    /// 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 callback. 
    /// The completion handler is always called on the main thread.
    /// </summary>
    /// <param name="callback">Background task completion callback.</param>
    public void GenerateIdentityVerificationSignatureWithCompletionHandler(Action<ISN_GKIdentityVerificationSignatureResult> callback);

    /// <summary>
    /// Retrieves all available saved games.
    /// </summary>
    public static void FetchSavedGames(Action<ISN_GKSavedGameFetchResult> callback);

    /// <summary>
    /// Saves game data under the specified name.
    /// </summary>
    public static void SavedGame(string name, byte[] data, Action<ISN_GKSavedGameSaveResult> callback);

    /// <summary>
    /// Deletes a specific saved game
    /// </summary>
    public static void DeleteSavedGame(ISN_GKSavedGame game, Action<SA_Result> callback);

    /// <summary>
    /// Loads specific saved game data
    /// </summary>
    public static void LoadGameData(ISN_GKSavedGame game, Action<ISN_GKSavedGameLoadResult> callback);

    /// <summary>
    /// Resolves conflicted saved games.
    /// </summary>
    public static void ResolveConflictingSavedGames(List<string> conflictedGames, byte[] data, Action<ISN_GKSavedGameFetchResult> callback);
}

ISN_GKGameCenterViewController


namespace SA.IOSNative.GameKit
...
public class ISN_GKGameCenterViewController
{
    /// <summary>
    /// Show configured view controller
    /// </summary>
    public void Show();

    /// <summary>
    /// The named leaderboard that is displayed by the view controller.
    /// The leaderboardIdentifier property must either be nil or it must match a leaderboard identifier 
    /// you defined when you created your leaderboards on iTunes Connect. If nil, the view displays scores for the aggregate leaderboard. 
    /// Default is nil.
    /// </summary>
    public string LeaderboardIdentifier  {get; set;}

    /// <summary>
    /// Gets or sets the leaderboard time scope.
    /// </summary>
    /// <value>The leaderboard time scope.</value>
    public ISN_GKLeaderboardTimeScope LeaderboardTimeScope {get; set;}

    /// <summary>
    /// The content displayed by the Game Center view controller.
    /// </summary>
    public ISN_GKGameCenterViewControllerState ViewState {get; set;}
}

ISN_GKGameCenterViewControllerState

namespace SA.IOSNative.GameKit
...
public enum ISN_GKGameCenterViewControllerState
{
    /// <summary>
    /// Indicates that the view controller should present the default screen.
    /// </summary>
    Default = -1,

    /// <summary>
    /// Indicates that the view controller presents leaderboard content. 
    /// </summary>
    Leaderboards,

    /// <summary>
    /// Indicates that the view controller presents achievements content.
    /// </summary>
    Achievements,

    /// <summary>
    /// Indicates that the view controller presents challenges content.
    /// </summary>
    Challenges
}

ISN_GKLocalPlayerListener


namespace SA.IOSNative.GameKit
...
public class ISN_GKLocalPlayerListener {

    /// <summary>
    /// Indicates that saved game data was modified.
    /// This method is usually called when a game is saved on device other than the device currently in use.
    /// </summary>
    public static SA_iEvent<ISN_GKSavedGameSaveResult> DidModifySavedGame {get;}

    /// <summary>
    /// Invoked when a conflict arises between different versions of the same saved game.
    /// Saved game files conflict when multiple devices write to the same saved game file while one or more of the devices are offline.
    /// The app must determine which saved game data is the correct data to use and then call the ResolveConflicts <see cref="ISN_GKLocalPlayer"/>
    /// </summary>
    public static SA_iEvent<ISN_GKSavedGameFetchResult> HasConflictingSavedGames {get;}
}

Saved Games

ISN_GKSavedGame


namespace SA.IOSNative.GameKit
...
public class ISN_GKSavedGame
{
    /// <summary>
    /// The name of the device that created the saved game data.
    /// 
    /// The device name is equal to whatever the user has named his or her device.
    /// For example, “Bob’s iPhone”, “John’s Macbook Pro”.
    /// </summary>
    public string DeviceName  {get; set;}

    /// <summary>
    /// The name of the saved game.
    /// You can allow users to name their own saved games, or you can create a saved game name automatically.
    /// </summary>
    public string Name  {get; set;}

    /// <summary>
    /// The date when the saved game file was modified.
    /// </summary>
    public DateTime ModificationDate  {get;}
}

ISN_GKSavedGameFetchResult

namespace SA.IOSNative.GameKit
...
public class ISN_GKSavedGameFetchResult : SA_Result
{
    /// <summary>
    /// Returns the saved games.
    /// </summary>
    public List<ISN_GKSavedGame> SavedGames {get;}
}

ISN_GKSavedGameLoadResult

public class ISN_GKSavedGameLoadResult : SA_Result
{
    /// <summary>
    /// Returns string representation of the data
    /// </summary>
    public string StringData  {get;}

    /// <summary>
    /// Returns bytes array representation of the data.
    /// </summary>
    public byte[] BytesArrayData  {get;}
}

ISN_GKSavedGameSaveResult

public class ISN_GKSavedGameSaveResult : SA_Result
{
    /// <summary>
    /// Returns the saved games.
    /// </summary>
    public ISN_GKSavedGame SavedGame {get;}
}

Achievements

ISN_GKAchievement


namespace SA.IOSNative.GameKit
...
public class ISN_GKAchievement 
{

    /// <summary>
    /// A string used to uniquely identify the specific achievement the object refers to.
    /// The identifier property must match the identifier string 
    /// for an achievement you created for your game on iTunes Connect.
    /// </summary>
    public string Identifier  {get;}

    /// <summary>
    /// A percentage value that states how far the player has progressed on this achievement.
    /// 
    /// The default value for a newly initialized achievement object is 0.0. 
    /// The range of legal values is between 0.0 and 100.0, inclusive. 
    /// You decide how that percentage is calculated and when it changes. 
    /// For example, if the player earns an achievement simply for discovering a location in your game, 
    /// then you would simply report the achievement as 100 percent complete 
    /// the first time you report progress to Game Center. 
    /// On the other hand, for an achievement like “Capture 10 pirates”, 
    /// your reporting mechanism increments by 10 percent each time the player captures a pirate.
    /// </summary>
    public float PercentComplete {get; set;}

    /// <summary>
    /// A Boolean value that states whether the player has completed the achievement.
    /// 
    /// The value of this property is <c>true</c> if the percentComplete property is equal to 100.0; 
    /// otherwise, it is <c>false</c>.
    /// </summary>
    public bool Completed {get;}

    /// <summary>
    /// The last time that progress on the achievement was successfully reported to Game Center.
    /// On a newly initialized achievement object, this property holds the current date.
    /// </summary>
    public DateTime LastReportedDate {get;}


    //--------------------------------------
    // Static Methods
    //--------------------------------------


    /// <summary>
    /// Loads previously submitted achievement progress for the local player from Game Center.
    /// 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. Listing 1 shows an example of how to load the local player’s achievements.
    ///
    /// </summary>
    /// <param name="callback">
    /// A block to be called when the download is completed.
    /// An array of <see cref="ISN_GKAchievement"/> objects that 
    /// represents all progress reported to Game Center for the local player. 
    /// If an error occurred, this parameter may be non-nil, 
    /// in which case the array holds whatever achievement information Game Kit was able to fetch.
    /// </param>
    public static void LoadAchievements(Action<ISN_GKAchievementsResult> callback);


    /// <summary>
    /// Resets all achievement progress for the local player.
    /// 
    /// Calling this class method deletes all progress towards achievements previously reported for the local player. 
    /// Hidden achievements that were previously visible are now hidden again.
    /// </summary>
    /// <param name="callback">A block to be called when the reset action is completed.</param>
    public static void ResetAchievements(Action<SA_Result> callback);

   
    /// <summary>
    /// Reports progress of achievement.
    /// Conisder using <see cref="ReportAchievements"/> instead
    /// </summary>
    /// <param name="achievement">achievements whose progress is being updated.</param>
    /// <param name="callback">A block to be called after the operation completes.</param>
    public static void ReportAchievement(ISN_GKAchievement achievement, Action<SA_Result> callback);


    /// <summary>
    /// Reports progress on an array of achievements.
    /// 
    /// Use this class method whenever you need to submit one or more achievement updates at the same time. 
    /// Calling this method reports each of the achievements in the array. 
    /// Processing multiple achievements at once allows the entire operation to be processed more efficiently 
    /// using this method as the callback handler is only called once.
    /// </summary>
    /// <param name="achievements">
    /// An array of <see cref="ISN_GKAchievement"/> objects 
    /// that contains the achievements whose progress is being updated.
    /// </param>
    /// <param name="callback">
    /// A block to be called after the operation completes.
    /// </param>
    public static void ReportAchievements(List<ISN_GKAchievement> achievements, Action<SA_Result> callback);
}

ISN_GKAchievementsResult

namespace SA.IOSNative.GameKit
...
public class ISN_GKAchievementsResult  : SA_Result
{
    /// <summary>
    /// An array of <see cref="ISN_GKAchievement"/> objects 
    /// that represents all progress reported to Game Center for the local player. 
    /// If an error occurred, this parameter may be non-null, 
    /// in which case the array holds whatever achievement information Game Kit was able to fetch.
    /// </summary>
    public List<ISN_GKAchievement> Achievements {get;}
}

Leaderboards

ISN_GKLeaderboard

namespace SA.IOSNative.GameKit
...
public class ISN_GKLeaderboard 
{
    //--------------------------------------
    // Get / Set
    //--------------------------------------


    /// <summary>
    /// The named leaderboard to retrieve information from.
    /// 
    /// If not empty, Game Center only returns scores from the matching leaderboard. 
    /// If empty, all scores previously reported by the game are searched. Default is <see cref="string.Empty"/>.
    /// </summary>
    public string Identifier {get; set;}


    /// <summary>
    /// The identifier for the group the leaderboard is part of.
    /// 
    /// If your game was configured to be part of a group in iTunes Connect, 
    /// this property holds the identifier you assigned to the group.
    /// </summary>
    /// <value>The group identifier.</value>
    public string GroupIdentifier {get; set;}

    /// <summary>
    /// The localized title for the leaderboard.
    /// 
    /// If you initialized a new leaderboard object, 
    /// this property is invalid until a call to <see cref="LoadScores"/> is complete. 
    /// Afterward, it contains the localized title for the leaderboard identified by the category property.
    /// </summary>
    public string Title {get; set;}

    /// <summary>
    /// A filter used to restrict the search to a subset of the players on Game Center.
    /// 
    /// The playerScope property is ignored if the leaderboard request was initialized using the initWithPlayerIDs: method. 
    /// Otherwise, the playerScope property determines which players are included in the request for high scores. 
    /// The default is <see cref="ISN_GKLeaderboardPlayerScope.Global"/>. See <see cref="ISN_GKLeaderboardPlayerScope"/> for more information.
    /// </summary>
    public ISN_GKLeaderboardPlayerScope PlayerScope {get; set;}


    /// <summary>
    /// A filter used to restrict the search to scores that were posted within a specific period of time.
    /// 
    /// This property determines how far back in time to look for scores. 
    /// The default value is <see cref="ISN_GKLeaderboardTimeScope.AllTime"/>. See <see cref="ISN_GKLeaderboardTimeScope"/> for more information.
    /// </summary>
    public ISN_GKLeaderboardTimeScope TimeScope {get; set;}


    /// <summary>
    /// The numerical score rankings to return from the search.
    /// 
    /// The range property is ignored if the leaderboard request was initialized using the initWithPlayerIDs: method. 
    /// Otherwise, the range property is used to filter which scores are returned to your game. 
    /// For example, if you specified a range of [1,10], after the search is complete, your game receives the best ten scores. 
    /// The default range is [1,25].
    /// 
    /// The minimum index is 1. The maximum length is 100.
    /// </summary>
    public ISN_NSRange Range {get; set;}


    /// <summary>
    /// The size of the leaderboard.
    /// 
    /// This property is invalid until a call to <see cref="LoadScores"/> is completed. 
    /// Afterward, it contains the total number of entries 
    /// available to return to your game given the filters you applied to the query.
    /// </summary>
    public long MaxRange {get;}

    /// <summary>
    /// A Boolean value that indicates whether the leaderboard object is retrieving scores.
    /// The value of the loading property is <c>true</c> 
    /// if the leaderboard object has any pending requests for scores.
    /// </summary>
    public bool Loading {get;}


    /// <summary>
    /// An array of GKScore objects that contains the scores returned by the search.
    /// 
    /// This property is invalid until a call to <see cref="LoadScores"/> is complete. 
    /// Afterward, it contains the same score objects that were returned to the completion handler.
    /// </summary>
    public List<ISN_GKScore> Scores {get;}

    /// <summary>
    /// The score earned by the local player.
    /// 
    /// This property is invalid until a call to <see cref="LoadScores"/>is completed. 
    /// Afterward, it contains a score object representing the local player’s score 
    /// on the leaderboard given the filters you applied to the query.
    /// </summary>
    public ISN_GKScore LocalPlayerScore {get;}


    //--------------------------------------
    // Public Methods
    //--------------------------------------


    /// <summary>
    /// Retrieves a set of scores from Game Center.
    /// 
    /// 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.
    /// </summary>
    /// <param name="callback">A block to be called after the scores are retrieved from the server.</param>
    public void LoadScores(Action<ISN_GKScoreLoadResult> callback);


    //--------------------------------------
    // Public Static Methods
    //--------------------------------------


    /// <summary>
    /// Loads the list of leaderboards from Game Center
    /// Use this class method to retrieve the list of leaderboards you configured on iTunes Connect. 
    /// </summary>
    /// <param name="callback">A block that is called when the categories have been retrieved from the server.</param>
    public static void LoadLeaderboards(Action<ISN_GKLeaderboardsResult> callback);

}

ISN_GKLeaderboardPlayerScope

public enum ISN_GKLeaderboardPlayerScope
{
    /// <summary>
    /// All players on Game Center should be considered when generating the list of scores.
    /// </summary>
    Global = 0,

    /// <summary>
    /// Only friends of the local player should be considered when generating the list of scores.
    /// </summary>
    FriendsOnly
}

ISN_GKLeaderboardsResult

namespace SA.IOSNative.GameKit
...
 public class ISN_GKLeaderboardsResult : SA_Result 
{
    /// <summary>
    /// An array of <see cref="ISN_GKLeaderboard"/> objects that provides the leaderboards for your game. 
    /// If an error occurred, this value may be non-null. 
    /// In this case, the array holds whatever data Game Kit was able to download before the error occurred.
    /// </summary>
    public List<ISN_GKLeaderboard> Leaderboards {get;}
}

ISN_GKLeaderboardTimeScope

namespace SA.IOSNative.GameKit
...
public enum ISN_GKLeaderboardTimeScope
{
    /// <summary>
    /// Each player is restricted to scores recorded in the past 24 hours.
    /// </summary>
    Today = 0,

    /// <summary>
    /// Each player is restricted to scores recorded in the past week.
    /// </summary>
    Week,

    /// <summary>
    /// Each player’s best score is returned.
    /// </summary>
    AllTime
}

ISN_GKScore

namespace SA.IOSNative.GameKit
...
public class ISN_GKScore 
{
    /// <summary>
    /// The position of the score in the results of a leaderboard search.
    /// 
    /// The value of this property is only valid on score objects returned from Game Center. 
    /// The rank property represents the position of the score in the returned results, with 1 being the best score, 2 being the second best, and so on.
    /// </summary>
    public long Rank {get;}

    /// <summary>
    /// The score earned by the player.
    /// 
    /// You can use any algorithm you want to calculate scores in your game. 
    /// Your game must set the value property before reporting a score, otherwise an error is returned.
    /// 
    ///  The value provided by a score object is interpreted by Game Center only when formatted for display.
    /// You determine how your scores are formatted when you define the leaderboard on iTunes Connect.
    /// </summary>
    public long Value {get;}

    /// <summary>
    /// An integer value used by your game.
    /// 
    /// The <see cref="Context"/> property is stored and returned to your game, 
    /// but is otherwise ignored by Game Center. 
    /// It allows your game to associate an arbitrary 64-bit unsigned integer value 
    /// with the score data reported to Game Center. 
    /// You decide how this integer value is interpreted by your game. 
    /// For example, you might use the <see cref="Context"/> property 
    /// to store flags that provide game-specific details about a player’s score, 
    /// or you might use the context as a key to other data stored on the device or on your own server. 
    /// The context is most useful when your game displays a custom leaderboard user interface.
    /// </summary>
    public long Context {get;}

    /// <summary>
    /// The date and time when the score was earned.
    /// 
    /// When you initialize the new score object, the date property is automatically set to the current date and time.
    /// </summary>
    public DateTime Date {get;}

    /// <summary>
    /// Returns the player’s score as a localized string
    /// 
    /// This property is invalid on a newly initialized score object. 
    /// On a score returned from GameKit, it contains a formatted string based on the player’s score. 
    /// You determine how a score is formatted when you define the leaderboard on iTunes Connect.
    ///
    /// Never convert the value property into a string directly; always use this method to receive the formatted string.
    /// 
    /// <c>Important</c>
    /// You may be tempted to write your own formatting code rather than using the formattedValue property. 
    /// Do not do this. Using the built-in support makes it easy to localize the score value into other languages, 
    /// and provides a string that is consistent with the presentation of your scores in the Game Center app.
    /// </summary>
    public string FormattedValue {get;}

    /// <summary>
    /// The identifier for the leaderboard.
    /// </summary>
    public string LeaderboardIdentifier {get;}

    /// <summary>
    /// The player identifier for the player that earned the score.
    /// 
    /// When you initialize a new score object, the <see cref="Player"/> property 
    /// is set to the identifier for the local player. 
    /// If the score object was returned to your game by loading scores from Game Center, 
    /// the <see cref="Player"/> property identifies the player who recorded that score.
    /// </summary>
    public ISN_GKPlayer Player {get;}
    }


    //--------------------------------------
    // Public Methods
    //--------------------------------------

    /// <summary>
    /// Reports score to Game Center
    /// Use this class method whenever you need to submit scores to Game Center.
    /// 
    /// If you nee to report multiple scores, consider using the <see cref="ReportScores"/> method
    /// </summary>
    /// <param name="callback">A block to be called after the score is reported.</param>
    public void Report(Action<SA_Result> callback);

    //--------------------------------------
    // Public Static Methods
    //--------------------------------------

    /// <summary>
    /// Reports a list of scores to Game Center
    /// 
    /// Use this class method whenever you need to submit scores to Game Center, 
    /// whether you are reporting a single score or multiple scores. 
    /// The method runs through the array of GKScore objects, submitting scores one at a time.
    /// 
    /// Method provides a sample method to report a score. 
    /// The <see cref="ISN_GKScore"/> object is initialized with the leaderboard ID 
    /// for the leaderboard it reports its score to and then the value and context for the score are assigned. 
    /// The leaderboard ID must be the identifier for a leaderboard you configured in iTunes Connect. 
    /// Scores are always reported for the current local player and never for friends.
    /// </summary>
    /// <param name="scores">An array of <see cref="ISN_GKScore"/> objects that contains the scores to report to Game Center.</param>
    /// <param name="callback">A block to be called after the score is reported.</param>
    public static void ReportScores(List<ISN_GKScore> scores, Action<SA_Result> callback);
    
}

ISN_GKScoreLoadResult

namespace SA.IOSNative.GameKit
...
public class ISN_GKScoreLoadResult : SA_Result
{
    /// <summary>
    /// An array of <see cref="ISN_GKScore"/> objects that holds the requested scores. 
    /// If an error occurred, this value may be non-nil. 
    /// In this case, the array holds whatever score data could be retrieved from Game Center before the error occurred.
    /// </summary>
    public List<ISN_GKScore> Scores {get;}

    /// <summary>
    /// Update Leaderboard request
    /// </summary>
    public ISN_GKLeaderboard Leaderboard {get;}
}

ISN_GKIdentityVerificationSignatureResult

using System;
using System.Collections.Generic;
using UnityEngine;

using SA.Foundation.Templates;

namespace SA.IOSNative.GameKit
...

/// <summary>
/// Game Kit signature generation result
/// </summary>
[Serializable]
public class ISN_GKIdentityVerificationSignatureResult : SA_Result
{
    /// <summary>
    /// The URL for the public encryption key.
    /// </summary>
    public string PublicKeyUrl {get;}


    /// <summary>
    /// The date and time that the signature was created.
    /// </summary>
    public long Timestamp {get;}


    /// <summary>
    /// The verification signature data generated.
    /// </summary>
    public byte[] Signature {get;}


    /// <summary>
    /// A random NSString used to compute the hash and keep it randomized.
    /// </summary>
    public byte[] Salt {get;}
}