Skip to content

Wortal SDK Core

Table of contents

Variables

Functions

Variables

ads

Const ads: ads = _ads

Ads API


analytics

Const analytics: analytics = _analytics

Analytics API


context

Const context: context = _context

Context API


iap

Const iap: iap = _iap

In-app purchase API


leaderboard

Const leaderboard: leaderboard = _leaderboard

Leaderboard API


notifications

Const notifications: notifications = _notifications

Notifications API


player

Const player: player = _player

Player API


session

Const session: session = _session

Session API


tournament

Const tournament: tournament = _tournament

Tournament API


isInitialized

isInitialized: boolean

Returns true if the SDK Core has been initialized.

Functions

getSupportedAPIs

getSupportedAPIs(): string[]

Gets the supported APIs for the current platform.

Example

const supportedAPIs = Wortal.getSupportedAPIs();
if (supportedAPIs.includes("context.shareAsync")) {
   shareWithFriendsDialog.show();
}

Returns

string[]

Array of supported APIs.


initializeAsync

initializeAsync(): Promise<void>

Initializes the SDK. This should be called before any other SDK functions. It is recommended to call this as soon as the script has been loaded to shorten the initialization time.

NOTE: This is only available if the manual initialization option is set to true. Otherwise, the SDK will initialize automatically.

Example

Wortal.initializeAsync().then(() => {
   // SDK is ready to use, wait for game to finish loading.
   Wortal.setLoadingProgress(100);
   Wortal.startGameAsync();
});

Returns

Promise<void>

Promise that resolves when the SDK initialized successfully.

Throws

  • INITIALIZATION_ERROR
  • NOT_SUPPORTED

onPause

onPause(callback): void

Sets a callback which will be invoked when the app is brought to the background,

Parameters

Name Type Description
callback () => void Callback to invoke.

Returns

void


performHapticFeedbackAsync

performHapticFeedbackAsync(): Promise<void>

Requests and performs haptic feedback on supported devices.

Returns

Promise<void>

Promise that resolves when the haptic feedback was requested successfully.

Throws

  • NOT_SUPPORTED
  • CLIENT_UNSUPPORTED_OPERATION
  • INVALID_OPERATION

setLoadingProgress

setLoadingProgress(value): void

Sets the loading progress value for the game. This is required on some platforms. Failure to call this with 100 once the game is fully loaded will result in the game failing to start.

Example

onGameLoadProgress(percent) {
    Wortal.setLoadingProgress(percent);
}

onGameLoaded() {
    Wortal.setLoadingProgress(100);
}

Parameters

Name Type Description
value number Percentage of loading complete. Range is 0 to 100.

Returns

void


startGameAsync

startGameAsync(): Promise<void>

This indicates that the game has finished initial loading and is ready to start. Context information will be up-to-date when the returned promise resolves. The loading screen will be removed after this is called along with the following conditions:

  • initializeAsync has been called and resolved
  • setLoadingProgress has been called with a value of 100

NOTE: This is only available if the manual initialization option is set to true. Otherwise, the game will start automatically.

Example

Wortal.startGameAsync().then(() => {
   // Game is rendered to player.
});

Returns

Promise<void>

Promise that resolves when the game has started successfully.

Throws

  • INITIALIZATION_ERROR
  • NOT_SUPPORTED

authenticateAsync

authenticateAsync(): Promise<AuthResponse>

Starts the authentication process for the player. If the current platform has its own authentication prompt then this will be displayed.

NOTE: This function might redirect or refresh the page, so it should be called before the game starts.

Example

Wortal.authenticateAsync().then(response => console.log(response));

Returns

Promise<AuthResponse>

Promise that resolves with the response from the authentication process.

Throws

  • AUTH_IN_PROGRESS
  • USER_ALREADY_AUTHENTICATED
  • USER_INPUT
  • NOT_SUPPORTED