Skip to main content
Version: 26.2.9

Classes

Skillz

Represents the main way to interact with Skillz.

abortMatch

Aborts the Skillz match in the activity.

static void abortMatch(Activity activity)
Parameters

activity Reference to the activity of your game's gameplay.


addMetadataForMatchInProgress

Updates the meta data for a Skillz match in progress.

static void addMetadataForMatchInProgress(java.util.Map<?,?> attributes, boolean isMatchInProgress)
Parameters

attributes A Map containing the metadata of the match in progress.

isMatchInProgress A boolean indicating if a match is in progress.


currentUserDisplayName

Returns the current Skillz user's display name.

static java.lang.String currentUserDisplayName(Activity activity)
Parameters

activity The instance of the Activity representing your game's gameplay.

Returns

A string representing the current user's display name.


getMatchInfo

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

static MatchInfo getMatchInfo(Activity activity)
Returns

A MatchInfo object.


getMatchRules

Returns a dictionary of gameplay parameters that you set in each match type in the Developer Console.

static java.util.Map<java.lang.String,java.lang.String> getMatchRules()
Returns

A Map containing the gameplay parameters for the match.


getPlayerDetails

Gets details of the currently logged in player.

static SkillzPlayer getPlayerDetails(Activity activity)
Returns

A SkillzPlayer object that contains info of the currently logged in player.


getRandom

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

static SkillzRandom getRandom()
Returns

A SkillzRandom object that wraps the random integer.


isMatchInProgress

Returns whether or not there is currently a Skillz match in progress.

static boolean isMatchInProgress()
Returns

A boolean indicating if a match is in progress.


launch

Launches the Skillz UI.

static void launch(Activity activity)

player

Returns a more general Player object with more fields to describe a player.

static Player player(Activity activity)
Parameters

activity An instance of the activity representing your game's gameplay.

Returns

A Player object.


registerPushToken

Enables an app to receive push notifications.

static void registerPushToken(Context context, java.lang.String pushToken)
Parameters

context The current application's context to receive Skillz push notifications.

pushToken The device's Firebase push token.


reportScore

Validate match id then reports a score to Skillz from a given activity.

static void reportScore(@NonNull final Activity activity, java.math.BigDecimal score, String matchId)
Parameters

activity The activity to report the score from.

score The score to report.

matchId The id of the current match.


SDKVersionShort

Returns the name of the Skillz SDK Version.

static java.lang.String SDKVersionShort()
Returns

The SDK Version as a string.


updatePlayersCurrentScore

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

static void updatePlayersCurrentScore(Activity activity, BigDecimal score, String matchId)
Parameters

activity The activity which contains the score to update.

score The player's updated score.

matchId The id of the current match.


SkillzSync

This class has methods to register an implementation of the SyncDelegate interface to support synchronous matches.

registerSyncDelegate

Call this method to register your delegate object that implements the SyncDelegate Interface.

static void registerSyncDelegate(SyncDelegate delegate, Activity activity) ;
Parameters

delegate The object that implements the callback methods to support synchronous play.

activity The activity of your game.


isMatchCompleted

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

static boolean isMatchCompleted();
Returns

A boolean indicating whether or not the match has been completed.


sendData

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

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).

static void sendData(@NonNull byte[] data);
Parameters

data The message to be sent.


getConnectedPlayerCount

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

static int getConnectedPlayerCount();
Returns

The numbers of players connected.


getOpponentPlayerId

Returns the opponent user's player ID for an in progress match. You can use this to fetch the opponent SKZSyncPlayer, or for variable passing.

static long getOpponentPlayerId();
Returns

An integer identifying the opponent user in the match.


getCurrentPlayerId

Returns the current user's player ID for an in progress match. You can use this to fetch the current SKZSyncPlayer, or for variable passing.

static long getCurrentPlayerId();
Returns

An integer identifying the current user in the match.


getServerTime

Returns the current server time so that you may synchronize via that rather than local device time.

Note: Not to be used for displaying the current date/time.

static double getServerTime();
Returns

The current time in seconds.


getTimeLeftForReconnection

A Skillz player only has this much time remaining to reconnect once disconnected, and is the actual time they have left when this method is called. Reconnect time is strictly decreasing and does not reset after successful connections to prevent griefing.

Note: If the value returned is negative, the player should be considered aborted from the match.

static long getTimeLeftForReconnection(long playerId);
Parameters

The player id of the disconnected player.

Returns

The current time in milliseconds.


Interfaces

SyncDelegate

Implement this interface and register it with SkillzSync to support synchronous matches.

onOpponentHasLostConnection

This method will be called when the opponent player has lost their connection. This method is not called when the game is finished nor when the opponent aborts the match.

You could, for example, use this routine to pause the match until the disconnected player is either reconnected or kicked if they don't reconnect within the allotted time.

void onOpponentHasLostConnection(long playerId);
Parameters

playerId The id of player who is attempting to reconnect. The long type is equivalent to SKZSyncPlayerId.


onOpponentHasReconnected

This method is called when a disconnected opposing player reconnects to the server within the allotted time.

Note: This method is also called the first time the current player successfully connects to the server.

You can use this method to resume play in a game that had been paused when the player disconnected.

void onOpponentHasReconnected(long playerId);
Parameters

playerId The id of player who has reconnected. The long type is equivalent to SKZSyncPlayerId.


onOpponentHasLeftMatch

This method is called when the opposing player disconnects from the server and does not reconnect within the allotted time. This will remove them from the match.

You should implement this method to halt the game and report the current player's score.

void onOpponentHasLeftMatch(long playerId);
Parameters

playerId The id of player who has permanently left the match. The long type is equivalent to SKZSyncPlayerId.


onCurrentPlayerHasLostConnection

This method will be called when the current player has lost their connection to the Skillz Server.

Note that the SDK will try to reestablish a connection to the server on its own, there is no specific action the game needs to perform in this situation.

void onCurrentPlayerHasLostConnection();

onCurrentPlayerHasReconnected

Analogous to onOpponentHasReconnected except it is the current player who has reconnected to server.

void onCurrentPlayerHasReconnected();

onCurrentPlayerHasLeftMatch

This method is called when the current player disconnects from the server and does not reconnect within the allotted time. This will remove them from the match.

The current player is permanently removed from the match, in much the same manner as if they had aborted the match.

Note: You should implement this method and abort the current player from the match.

void onCurrentPlayerHasLeftMatch();

onDidReceiveData

This method receives an array of data that had been sent by the other player.

void onDidReceiveData(@NonNull byte[] data);
Parameters

data The message sent by the other player.


onMatchCompleted

This method will be triggered on all clients when one client has explicitly reported a score or aborted.

void onMatchCompleted();