Skillz Class Reference

Inherits from NSObject
Declared in SkillzInstance.h

Overview

Main interface for the Skillz SDK

Warning: Starting and Ending a Tournament

Note: Use existing methods for ending and beginning a match that are defined in SkillzInstance.h

You should implement tournamentWillBegin:withMatchInfo:, which will be called when a match should begin. You can check the supplied SKZMatchInfo’s isSynchronous property to determine whether the match is Sync or Async.

For reporting a player’s score, you should use displayTournamentResultsWithScore:withCompletion:.

For aborting a player, you should use notifyPlayerAbortWithCompletion:

Skillz SDK Properties

  tournamentIsInProgress

Whether or not a Skillz match is currently in progress.

@property (readonly, assign) BOOL tournamentIsInProgress

Declared In

SkillzInstance.h

  skillzDelegate

The current SkillzBaseDelegate instance

@property (readonly, strong) id<SkillzBaseDelegate> skillzDelegate

Declared In

SkillzInstance.h

Skillz SDK Class Methods

+ skillzInstance

Get a singleton reference to the Skillz SDK

+ (Skillz *)skillzInstance

Return Value

The singleton instance of the Skillz SDK object

Declared In

SkillzInstance.h

+ getMatchRules

Returns a Dictionary of Game Parameters that you set in each tournament in Developer Portal.

+ (NSDictionary *)getMatchRules

Discussion

You can set or edit these game parameters by clicking Tournaments > Edit in your Developer Portal (https://developers.skillz.com/dashboard))

You can use these game parameters to provide a different user experience for each tournament that you have.

Declared In

SkillzInstance.h

+ getRandomNumber

Returns a random integer supplied by the Skillz SDK to ensure fairness across competition games.

+ (NSInteger)getRandomNumber

Discussion

The range of this function is [0, RAND_MAX) (0 is inclusive, RAND_MAX is exclusive)

On iOS, RAND_MAX is 2,147,483,647

Players in the same tournament will receive the same sequence of random numbers.

Declared In

SkillzInstance.h

+ getRandomFloat

Returns a random floating point value supplied by the Skillz SDK to ensure fairness across competition games.

+ (CGFloat)getRandomFloat

Discussion

The range of this function is [0, 1.0) (0 is inclusive, 1.0 is exclusive)

Players in the same tournament will receive the same sequence of random numbers.

Declared In

SkillzInstance.h

+ getRandomNumberWithMin:andMax:

Returns a random unsigned integer supplied by the Skillz SDK to ensure fairness across competition games.

+ (NSUInteger)getRandomNumberWithMin:(NSUInteger)min andMax:(NSUInteger)max

Parameters

min

The minimum possible value returned, inclusive.

max

The maximum possible value returned, exclusive.

Discussion

Number will be in the range [min,max) (min is inclusive, max is exclusive), and the probability will be evenly distributed amongst all the possible values.

[Skillz skillzgetRandomNumberWithMin:2 andMax:10] will return one of the following numbers with equal probability: 2,3,4,5,6,7,8,9

Players in the same tournament will receive the same sequence of random numbers.

Declared In

SkillzInstance.h

Skillz SDK Instance Methods

– initWithGameId:forDelegate:withEnvironment:allowExit:

Initialize Skillz

- (void)initWithGameId:(NSString *)gameId forDelegate:(id<SkillzBaseDelegate>)delegate withEnvironment:(SkillzEnvironment)environment allowExit:(BOOL)allowExit

Parameters

gameId

Your game ID as given to you on the Skillz developer portal

delegate

This delegate must implement all required methods of the SkillzBaseDelegate protocol

environment

SkillzSandbox for sandbox testing or SkillzProduction for app store submission.

allowExit

Whether to allow the user to exit the Skillz experience

Discussion

This needs to be called within application:didFinishLaunchingWithOptions in your App Delegate. Will not launch the Skillz experience, this function only establishes the connection between your game and the SkillzEnvironment of choice.

Declared In

SkillzInstance.h

– launchSkillz

Launch the Skillz Experience

- (void)launchSkillz

Discussion

This function is what will actually render the Skillz experience on screen. This function will draw a ViewController onto your view hierarchy.

Because of this, do not call this method while attempting to draw another ViewController on screen as well.

Declared In

SkillzInstance.h

– getMatchInfo

Use this method to fetch the match information of the current match.

- (SKZMatchInfo *)getMatchInfo

Return Value

A SKZMatchInfo containing information identifying the match and players within the match.

Declared In

SkillzInstance.h

– updatePlayersCurrentScore:

This method must be called each time the current player’s score changes during a Skillz match.

- (void)updatePlayersCurrentScore:(NSNumber *)currentScoreForPlayer

Parameters

currentScoreForPlayer

Current score value for the player

Discussion

For example, in many games this method is called when the player scores points, when the player is penalized, and whenever a time bonus is applied. It is OK for this method to be called very often.

If a continuous in-game score is displayed to the player, this method is generally called as often as that score display is updated - usually by placing the updatePlayersCurrentScore call in the same place within the game loop.

Declared In

SkillzInstance.h

– displayTournamentResultsWithScore:withCompletion:

Call this function to report the player’s score to Skillz. Ends the current tournament, and returns the user to the Skillz experience.

- (void)displayTournamentResultsWithScore:(NSNumber *)score withCompletion:(void ( ^ ) ( void ))completion

Parameters

score

Numeric value representing the player’s final score

completion

Completion will be called on wrap up so that the developer can finish any ongoing processes, such as saving game data or removing the game from the view hierarchy.

Note: If your game is resource intensive, you should attempt to release as much memory as possible prior to calling this method.

Declared In

SkillzInstance.h

– notifyPlayerAbortWithCompletion:

Call this function when a player aborts a Skillz match in progress. Forfeits the match and brings the user back into the Skillz experience.

- (void)notifyPlayerAbortWithCompletion:(void ( ^ ) ( void ))completion

Parameters

completion

Completion will be called on wrap up so that the developer can finish any ongoing processes, such as saving game data or removing the game from the view hierarchy.

Note: If your game is resource intensive, you should attempt to release as much memory as possible prior to calling this method.

Declared In

SkillzInstance.h

– setGameHasBackgroundMusic:

If your game plays its own background music that you’d like to play in the Skillz UI, set hasBackgroundMusic to YES to prevent the Skillz music from being played.

- (void)setGameHasBackgroundMusic:(BOOL)hasBackgroundMusic

Parameters

hasBackgroundMusic

Whether or not your game uses background music.

Declared In

SkillzInstance.h

– gameCanReviewTurn

Used internally to determine if a game has implemented the review turn feature.

- (BOOL)gameCanReviewTurn

Declared In

Skillz+TurnBased.h

Skillz SDK Information

+ SDKShortVersion

Get the version of the Skillz SDK

+ (NSString *)SDKShortVersion

Return Value

The SDK Version

Declared In

SkillzInstance.h

+ showSDKVersionInfo

Display the long version of SDK Info in a UIAlertView

+ (void)showSDKVersionInfo

Declared In

SkillzInstance.h

+ isSkillzPresented

This will return a value confirming whether or not the Skillz UI is currently presented

+ (BOOL)isSkillzPresented

Return Value

True if Skillz UI is currently presented, otherwise false.

Declared In

SkillzInstance.h

+ skillzOrientation

This will return the UIInterfaceOrientationMask set for Skillz, typically this is only used by our UnityViewControllerBase.

+ (UIInterfaceOrientationMask)skillzOrientation

Return Value

UIInterfaceOrientationMask for Skillz

Declared In

SkillzInstance.h

+ player

Get the current logged in player. Use this method if you need this information outside of a tournament.

+ (SKZPlayer *)player

Return Value

SKZPlayer object that represent the current player. If there is no player currently logged in, will return nil.

Declared In

SkillzInstance.h

+ currentUserDisplayName

DEPRECATED: Use the player method instead.

+ (NSString *)currentUserDisplayName

Declared In

SkillzInstance.h

– initWithGameId:forDelegate:withEnvironment:

Deprecated, use

- (void)initWithGameId:(NSString *)gameId forDelegate:(id<SkillzBaseDelegate>)delegate withEnvironment:(SkillzEnvironment)environment

Parameters

gameId

Skillz ID for your game

delegate

Delegate responsible for handling Skillz protocol call backs

environment

Environment to point the SDK to (Production or Sandbox)

Declared In

SkillzInstance.h

SyncPlay Methods

– sendData:

Call this method in order to send a message to all clients connected to this match. This will trigger onDidReceiveData: on all clients connected to the current match.

- (void)sendData:(NSData *_Nonnull)data

Parameters

message

The message to be sent.

Discussion

Note: NSData passed to this function are limited to a certain size based on the game, and this function will assert if over that size. (2048 bytes currently) Please reach out to integrations@skillz.com for more information.

Declared In

Skillz+SyncPlay.h

– isMatchCompleted

This will return whether or not another client connected to this match has called either displaySynchronousTournamentResultsWithScore or initiateSynchronousAbortWithCompletion: to end the match.

- (BOOL)isMatchCompleted

Return Value

Whether or not the match has been completed.

Declared In

Skillz+SyncPlay.h

– getConnectedPlayerCount

Use this method to query the number of players currently connected to a match.

- (NSInteger)getConnectedPlayerCount

Return Value

The numbers of players connected.

Declared In

Skillz+SyncPlay.h

– getCurrentPlayerId

This will return the current user’s player ID for an in progress match. You can use this to easily fetch the current SKZSyncPlayer, or for use in variable passing.

- (SKZSyncPlayerId)getCurrentPlayerId

Return Value

Integer identifying the current user in the match.

Declared In

Skillz+SyncPlay.h

– getCurrentOpponentPlayerId

This will return the current user’s opponent player ID for an in progress match. You can use this to easily fetch the current SKZSyncPlayer, or for use in variable passing.

- (SKZSyncPlayerId)getCurrentOpponentPlayerId

Return Value

Integer identifying the current user in the match.

Declared In

Skillz+SyncPlay.h

– getServerTime

Will return the current server time so that you may synchronize via that rather than local device time. Note: Do not use this to display a time and date.

- (double)getServerTime

Return Value

Current time in seconds

Declared In

Skillz+SyncPlay.h

– getTimeLeftForReconnection:

A player only has this much time remaining to reconnect once disconnected. This is the actual time they have left when this method is called. Note: If the value returned is negative, the player should be considered aborted from the match.

- (uint64_t)getTimeLeftForReconnection:(SKZSyncPlayerId)playerId

Parameters

The

player id of the disconnected player.

Return Value

Current time in milliseconds

Declared In

Skillz+SyncPlay.h

TurnBased Methods

– finishReviewingCurrentGameState:

When your user has finished reviewing the current game state, use this method to return to the Skillz UI.

- (void)finishReviewingCurrentGameState:(void ( ^ ) ( void ))completion

Parameters

completion

Called after Skillz UI has been displayed, use to clean up any outstanding objects in your game hierarchy.

Declared In

Skillz+TurnBased.h

– completeTurnWithGameData:playerScore:playerCurrentTotalScore:opponentCurrentTotalScore:roundOutcome:matchOutcome:withCompletion:

Completes a turn for a game, giving you access to a full range of options to convey to Skillz the final outcome of the match. If a value does not pertain to your game, pass nil. You must track and update playerTotalScore and opponentTotalScore yourself each turn.

- (void)completeTurnWithGameData:(NSString *)gameData playerScore:(NSString *)score playerCurrentTotalScore:(NSNumber *)playerCurrentTotalScore opponentCurrentTotalScore:(NSNumber *)opponentCurrentTotalScore roundOutcome:(SKZTurnBasedRoundOutcome)turnOutcome matchOutcome:(SKZTurnBasedMatchOutcome)matchOutcome withCompletion:(void ( ^ ) ( void ))completion

Parameters

gameData

A Base64 encoded NSString object containing serialized data which can be used to reconstruct the game state for the next turn, or to

score

The score the current user has obtained for this turn, this will be displayed in the Skillz UI, not used to calculate match outcomes.

playerCurrentTotalScore

The final score for the current player, passing nil will not modify the current player’s score. Also used in Skillz UI, not match outcomes

opponentCurrentTotalScore

The final score for the opponent player, passing nil will not modify the opponent’s score. Also used in Skillz UI, not match outcomes

turnOutcome

Passed to determine the outcome of a round. Round outcomes are used with in the Skillz UI. See SKZTurnBasedRoundOutcome for more information.

matchOutcome

Passed to determine the state of the match. Match outcomes determine the outcome of the match as whole, be it Win, Lose, or Tie. Pass “kSKZMatchOutcomeMatchNoOutcome” to continue play and pass control to opponent. See SKZTurnBasedRoundOutcome for more information.

completion

Called after Skillz UI has been displayed, use to clean up any outstanding objects in your game hierarchy.

Declared In

Skillz+TurnBased.h

Analytics Methods

– addMetadata:forMatchInProgress:

You may use this method to track player actions, level types, or other information pertinent to your Skillz integration. There should be no more than 10 Key Value pairs in the supplied attributes dictionary, excess values will be trimmed. Collected data will only be available to Skillz and will help Skillz identify fairness in level based games.

- (void)addMetadata:(nonnull NSDictionary *)attributes forMatchInProgress:(BOOL)forMatchInProgress

Parameters

attributes

Values to be recorded. Keys and values must be strings. Keys must be less than 50 characters, values must be less than 200 characters.

forMatchInProgress

If this relates to an in progress match additional match info will be tracked with these attributes.

Declared In

Skillz+Analytics.h