Skip to main content
Version: 26.2.9

Cordova

NOTE

Cordova is asynchronous in nature, so all the methods in the Skillz Cordova API are as well.

Classes

SkillzCordova

Represents the main point of interaction with Skillz.

skillzInit(gameId, environment)

Initializes Skillz.

SkillzCordova.skillzInit('YOUR-GAME-ID', 'SkillzSandbox')
Parameters

gameId String you get from your configuration in the developer console.

environment The Skillz environment should be ‘SkillzSandbox’ for testing purposes and ‘SkillzProduction’ when you’re ready to go live.


launchSkillz()

Used to launch the Skillz UI.

SkillzCordova.launchSkillz()

isMatchInProgress(completion)

Checks if a match is in progress.

SkillzCordova.isMatchInProgress(completion)
Parameters

completion A completion block that is executed after this method completes. You can use this completion block to set a local variable to the return value of this function.

Returns

True if a match is in progress; otherwise, false.


reportScore(score, matchId)

Reports the users final score for the current match, and returns to the Skillz UI.

SkillzCordova.reportScore(score, matchId)
Parameters

score A number.

matchId A number representing the current match ID.

updatePlayersCurrentScore(score, matchId)

Updates the user’s current score. Call this as the user's score is updated during a match.

SkillzCordova.updatePlayersCurrentScore(score, matchId)
Parameters

score The player's score as a number.

matchId A number representing the current match's ID.


abortMatch(matchId)

Forfeits the match and returns to the Skillz UI.

SkillzCordova.abortMatch(matchId)
Parameters

matchId The ID of the current match as a number.


getMatchRules(completion)

Returns a JSON object of the game parameters that were set in the Skillz Developer Console.

SkillzCordova.getMatchRules(completion)
Parameters

completion A callback function that is invoked after the method has completed.


getMatchInfo(completion)

Returns a JSON object with the current match’s information.

The match information object will contain the match id which will be used for updatePlayersCurrentScore, reportScore, and abortMatch function calls.

SkillzCordova.getMatchInfo(completion)
Parameters

completion A callback function that is invoked after this method has completed.


getCurrentPlayer(completion)

Returns a JSON object with the current player’s information.

SkillzCordova.getCurrentPlayer(completion)
Parameters

completion A callback function that is invoked after this method has completed.


getSDKVersion(completion)

Returns the current Skillz SDK your app is on as a string.

SkillzCordova.getSDKVersion(completion)
Parameters

completion A callback function that is invoked after this method has completed.


getRandomNumber(completion)

Returns a random number.

SkillzCordova.getRandomNumber(completion)
Parameters

completion A callback function that is invoked after this method has completed. This will pass the random number as an argument.


getRandomFloat(completion)

Returns a random float.

SkillzCordova.getRandomFloat(completion)
Parameters

completion A callback function that is invoked after this method has completed. This will pass the random float as an argument.


getRandomNumberWithRange(min, max, completion)

Returns a random number between the minimum and maximum value you passed in.

SkillzCordova.getRandomNumberWithRange(min, max, completion)

Parameters

min The minumum value of the random number.

max The maximum value of the maximum number.

completion A callback function that is invoked after this method has completed. This will pass the random float as an argument.


SkillzDelegateCordova

This class has methods that are invoked by Skillz, so you will need to implement them.

OnMatchWillBegin

This function is called by Skillz when a match is about to begin.

When this function gets called, the ‘matchInfo’ variable inside SkillzDelegateCordova gets set. You’ll be able to use this variable to set any game values needed when starting a match.

static OnMatchWillBegin(matchInfoString);
Parameters

matchInfoString A JSON formatted string containing information of the match. You can use JSON.parse(matchInfoString) to deserialize it into a JSON object.


onSkillzWillExit

Called by Skillz when a user chooses to exit the Skillz UI via the sidebar menu. Be sure to load the relevant portion of your game's UI when this happens, or the screen will be blank.

static onSkillzWillExit();