API Reference

Variables


Functions

LinkGame.getAdUnitsAsync#

getAdUnitsAsync(): Promise‹AdUnit[]›

Call signature defined in sdk/index.ts:581

Get a list of available ad units in current game

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.getAdUnitsAsync().then((adUnits) => {
console.log(adUnits)
});

Returns: Promise‹AdUnit[]›

LinkGame.getEntryPointAsync#

getEntryPointAsync(): Promise‹string›

Call signature defined in sdk/index.ts:488

Get information about where the game is started.

example

// Should be called after LinkGame.initializeAsync() resolves
LinkGame.getEntryPointAsync().then(entryPoint => {
console.log(entryPoint) // 'tab_banner'
})

Returns: Promise‹string›

LinkGame.getEntryPointData#

getEntryPointData(): EntryPointData

Call signature defined in sdk/index.ts:249

Get the entry point data bound to the entry point.

example

// Should be called after LinkGame.initializeAsync() resolves
LinkGame.getEntryPointData() // { from: 'prequel-game' }

Returns: EntryPointData

LinkGame.getInterstitialAdAsync#

getInterstitialAdAsync(placementId: string): Promise‹InterstitialAdInstance

Call signature defined in sdk/index.ts:380

Get AdInstance of an interstitial ad placement.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.getInterstitialAdAsync('DUMMY_PLACEMENT_ID')
.then(adInstance => {
// do something
})

Parameters:

NameType
placementIdstring

Returns: Promise‹InterstitialAdInstance

LinkGame.getLeaderboardAsync#

getLeaderboardAsync(name: string): Promise‹Leaderboard

Call signature defined in sdk/index.ts:334

Get a leaderboard by its name

example

LinkGame.getLeaderboardAsync('some_leaderboard')
.then(leaderboard => {
console.log(leaderboard.getName()) // 'some_leaderboard'
})

Parameters:

NameTypeDescription
namestringThe name of the leaderboard

Returns: Promise‹Leaderboard

LinkGame.getLocale#

getLocale(): string

Call signature defined in sdk/index.ts:237

Get the current player's locale information. Locale code will be based on navigator.language in the WebView, format will be align with BCP47.

example

LinkGame.getLocale() // 'ru-RU'

Returns: string

LinkGame.getPlatform#

getPlatform(): Platform

Call signature defined in sdk/index.ts:500

Get information about from which platform the game is started, regarding OS or browser.

example

console.log(LinkGame.getPlatform()) // 'ANDROID'

Returns: Platform

LinkGame.getRewardedVideoAsync#

getRewardedVideoAsync(placementId: string): Promise‹RewardedVideoInstance

Call signature defined in sdk/index.ts:405

Get AdInstance of a rewarded video ad placement.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.getRewardedVideoAsync('DUMMY_PLACEMENT_ID')
.then(adInstance => {
// do something
})

Parameters:

NameType
placementIdstring

Returns: Promise‹RewardedVideoInstance

LinkGame.getTrafficSource#

getTrafficSource(): TrafficSource

Call signature defined in sdk/index.ts:474

Get traffic source info. This unveals the the URL parameters attached to the game's URL.

Experimental support: please note that this API is subject to breaking change.

example

// Should be called after LinkGame.initializeAsync() resolves
const trafficSource = LinkGame.getTrafficSource()
console.log(trafficSource['utm_entrypoint']) // 'share'

Returns: TrafficSource

LinkGame.initializeAsync#

initializeAsync(options: InitializationOptions): Promise‹void›

Call signature defined in sdk/index.ts:73

Initialize the SDK for the game. In the background, SDK will try to setup environment and retrieve data for later use in the game. We recommend calling this API in the game ASAP to shorten the total loading wait time for players.

example

LinkGame.initializeAsync().then(() => {
// Initialize player session with game backend
})

Parameters:

NameTypeDefaultDescription
optionsInitializationOptions{}Extra options to alter the runtime behavior of the SDK.

Returns: Promise‹void›

LinkGame.onPause#

onPause(fn: function): void

Call signature defined in sdk/index.ts:263

Set a callback which will be invoked when the app is brought to background.

example

LinkGame.onPause(() => {
pauseGameplay()
})

Parameters:

fn: function

(): void

Returns: void

LinkGame.openDeeplinkAsync#

openDeeplinkAsync(category: string, params: string): Promise‹void›

Call signature defined in sdk/index.ts:599

Open deeplink in Link

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.openDeeplinkAsync('news', '/weather?mode=gps').then(function(res) {
console.log(res);
}).catch(function(err) {
console.log(err)
});

Parameters:

NameType
categorystring
paramsstring

Returns: Promise‹void›

LinkGame.openUrlAsync#

openUrlAsync(url: string): Promise‹void›

Call signature defined in sdk/index.ts:617

Open event link in Link

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.openUrlAsync('https://service.link.link/').then(function(res) {
console.log(res);
}).catch(function(err) {
console.log(err)
});

Parameters:

NameType
urlstring

Returns: Promise‹void›

LinkGame.setLoadingProgress#

setLoadingProgress(percentage: number): void

Call signature defined in sdk/index.ts:125

Updates the load progress of the game. The value will be shown at the loading screen.

example

LinkGame.setLoadingProgress(50) // The game is halfway loaded

Parameters:

NameTypeDefaultDescription
percentagenumber0Represents percentage of loading progress. It should be between 0 and 100.

Returns: void

LinkGame.shareAsync#

shareAsync(payload: SharePayload): Promise‹ShareResult›

Call signature defined in sdk/index.ts:213

Share messages to the player's friends. This will display an interactive UI for the user to choose who to share. Additional parameters can be used to fine-tune the message to be shared.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.shareAsync({
image: base64Picture,
text: {
default: 'Some text',
localizations: {
ja_JP: 'テキスト',
en_US: 'Some text',
}
}
caption: 'Some caption',
data: { someData: '...' },
}).then(function(shareResult) {
console.log(shareResult); // {sharedCount: 3}
});

Parameters:

NameTypeDescription
payloadSharePayloadAn object describes the message to be shared.

Returns: Promise‹ShareResult›

LinkGame.startGameAsync#

startGameAsync(): Promise‹void›

Call signature defined in sdk/index.ts:142

Starts the game. Calling this method will turn off the loading screen as soon as these requirements are met:

  • LinkGame.setLoadingProgress() is called with a number > 99
  • LinkGame.initializeAsync() is called and resolved

example

LinkGame.startGameAsync().then(() => {
myAwesomeGame.start()
})

Returns: Promise‹void›

LinkGame.updateAsync#

updateAsync(payload: CustomUpdatePayload): Promise‹void›

Call signature defined in sdk/index.ts:168

Post an update to the corresponding context. If the game is played in a messenger chat thread, this will send a message into the thread with specified image and text message and custom data payload.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.updateAsync({
image: base64Picture,
text: {
default: 'Some text',
localizations: {
ja_JP: 'テキスト',
en_US: 'Some text',
}
}
caption: 'Some caption',
data: { someData: '...' },
})

Parameters:

NameTypeDescription
payloadCustomUpdatePayloadAn object describes the update message

Returns: Promise‹void›


Functions

LinkGame.context.chooseAsync#

chooseAsync(payload: ContextChoosePayload): Promise‹void›

Call signature defined in sdk/context.ts:222

Display a UI to interactively choose a friend and create a context and send an invitation right away. Additional parameters can be specified to fine-tune the invitation message.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.context.chooseAsync({
image: base64Picture,
text: {
default: 'Some text',
localizations: {
ja_JP: 'テキスト',
en_US: 'Some text',
}
}
caption: 'Some caption',
data: { someData: '...' },
}).then(() => {
console.log(LinkGame.context.getID()); // 'SOMECONTEXT1234567'
});

Parameters:

NameTypeDescription
payloadContextChoosePayloadAdditional parameters for the UI

Returns: Promise‹void›

LinkGame.context.createAsync#

createAsync(playerId: string, payload: ContextCreatePayload): Promise‹void›

Call signature defined in sdk/context.ts:110

Create a context with an opponent player

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.context.createAsync('SOMEPLAYER123456', {
text: '{{senderName}} want to play with {{receiverName}} at {{gameName}}.',
caption: {
default: 'Some text',
localizations: {
ja_JP: 'テキスト',
en_US: 'Some text',
}
}
}).then(() => {
console.log(LinkGame.context.getID()); // 'SOMECONTEXT1234567'
});

Parameters:

NameTypeDefaultDescription
playerIdstring-Player ID of the opponent player
payloadContextCreatePayload{}Additional parameters for main text and action button on the popup UI

Returns: Promise‹void›

LinkGame.context.getID#

getID(): string | null

Call signature defined in sdk/context.ts:28

Get ID of current context

example

// In SOLO context
LinkGame.context.getID(); // null
// In THREAD context
LinkGame.context.getID(); // a 16 char alphanumeric string

Returns: string | null

LinkGame.context.getPlayersAsync#

getPlayersAsync(): Promise‹ContextPlayer[]›

Call signature defined in sdk/context.ts:248

Get players in current context

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.context.getPlayersAsync().then(players => {
console.log(player.length); // 2
});

Returns: Promise‹ContextPlayer[]›

LinkGame.context.getType#

getType(): "SOLO" | "THREAD"

Call signature defined in sdk/context.ts:40

Get type of current context

example

// In SOLO context
LinkGame.context.getType(); // 'SOLO'

Returns: "SOLO" | "THREAD"

LinkGame.context.isSizeBetween#

isSizeBetween(minSize?: undefined | number, maxSize?: undefined | number): ContextSizeResponse | null

Call signature defined in sdk/context.ts:57

Check if the count of players in current context is between given numbers

Experimental support: please note that this API is subject to breaking change.

example

// In a THREAD context containing 2 players
const result = LinkGame.context.isSizeBetween(2, 3);
console.log(result.answer); // true

Parameters:

NameTypeDescription
minSize?undefined | numberThe minimum boundry of the check
maxSize?undefined | numberThe maximum boundry of the check

Returns: ContextSizeResponse | null

LinkGame.context.switchAsync#

switchAsync(contextId: string, payload: ContextCreatePayload): Promise‹void›

Call signature defined in sdk/context.ts:165

Switch context by using a known context ID.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.context.switchAsync('SOMECONTEXT1234567', {
text: '{{senderName}} want to play with {{receiverName}} at {{gameName}}.',
caption: {
default: 'Some text',
localizations: {
ja_JP: 'テキスト',
en_US: 'Some text',
}
}
}).then(() => {
console.log(LinkGame.context.getID()); // 'SOMECONTEXT1234567'
});

Parameters:

NameTypeDefaultDescription
contextIdstring-Context ID of the context
payloadContextCreatePayload{}Additional parameters for main text and action button on the popup UI

Returns: Promise‹void›


Functions

LinkGame.player.flushDataAsync#

flushDataAsync(): Promise‹void›

Call signature defined in sdk/player.ts:85

Will flush any unsaved data to platform storage

Returns: Promise‹void›

LinkGame.player.getConnectedPlayersAsync#

getConnectedPlayersAsync(): Promise‹Array‹ConnectedPlayer››

Call signature defined in sdk/player.ts:194

This returns an array containing the friends of the user who has played the current game before.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.player.getConnectedPlayersAsync()
.then(players => {
console.log(players.map(player => {
return {
id: player.getID(),
name: player.getName(),
}
}))
// [{id: 'SOMEPLAYER123456', name: 'John'}, {id: 'SOMEPLAYER654321', name: 'Jack'}]
})

Returns: Promise‹Array‹ConnectedPlayer››

Array of connected players

LinkGame.player.getDataAsync#

getDataAsync(keys: string[]): Promise‹PlayerData›

Call signature defined in sdk/player.ts:34

Get game data from platform storage.

example

LinkGame.player
.getDataAsync(['hp', 'items'])
.then(function(data) {
console.log(data['hp']) // 100
console.log(data['items']) // {potion: 3, gold: 20}
})

Parameters:

NameTypeDescription
keysstring[]An array of unique keys to retrieve data for.

Returns: Promise‹PlayerData›

Latest snapshot of game data

LinkGame.player.getID#

getID(): string | null

Call signature defined in sdk/player.ts:97

Get the player's ID.

example

LinkGame.player.getID() // 'SOMEPLAYER123456'

Returns: string | null

Player's ID

LinkGame.player.getName#

getName(): string | null

Call signature defined in sdk/player.ts:109

Get the player's name.

example

LinkGame.player.getName() // 'John Smith'

Returns: string | null

Player's name

LinkGame.player.getPhoto#

getPhoto(): string | null

Call signature defined in sdk/player.ts:123

Get the player's photo.

example

const playerImage = new Image()
playerImage.crossOrigin = 'anonymous'
playerImage.src = LinkGame.player.getPhoto()

Returns: string | null

URL of player photo

LinkGame.player.getSignedPlayerInfoAsync#

getSignedPlayerInfoAsync(payload?: undefined | string): Promise‹SignedPlayerInfo

Call signature defined in sdk/player.ts:158

Get a [[SignedPlayerInfo]] object with custom payload and a signature. This can be useful for game server to validate if the user's identity and its payload is really sent from the game or tampered. Please read more on [[SignedPlayerInfo]] for more information.

example

LinkGame.player.getSignedPlayerInfoAsync('{"type":"GAIN_COINS","amount":100}')
.then(result => {
// Send to server for validation and further processing
sendToGameServer(
result.getPlayerID(),
result.getSignature(),
'{"type":"GAIN_COINS","amount":100}',
)
})

Parameters:

NameTypeDescription
payload?undefined | stringAn arbitary string to be signed

Returns: Promise‹SignedPlayerInfo

An object containing signed player info and custom payload

LinkGame.player.hasPlayed#

hasPlayed(): boolean

Call signature defined in sdk/player.ts:135

Get info about if the player has played the game.

example

LinkGame.player.hasPlayed() // true

Returns: boolean

Always true

LinkGame.player.setDataAsync#

setDataAsync(data: Record‹string, unknown›): Promise‹void›

Call signature defined in sdk/player.ts:74

Update game data to platform storage. The update will be merged into existing game data. Please be careful not to store a game data bigger than 1MB when stringified, which will cause the modification be rejected.

example

LinkGame.player
.setDataAsync({
items: {
potion: 4,
gold: 20,
},
hp: 99,
})
.then(function() {
console.log('data is set')
})

Parameters:

NameTypeDescription
dataRecord‹string, unknown›An object containing a set of key-value pairs. The object must contain only serializable values. Nullable value will be treated as removal of the key-value pair.

Returns: Promise‹void›


Classes

InterstitialAdInstance#

InterstitialAdInstance:

Class defined in models/ad-instance.ts:59

Methods

getPlacementID#

getPlacementID(): string

Call signature defined in models/ad-instance.ts:45

Get the ad's placement ID.

example

adInstance.getPlacementID() // '5458282176661711'

Returns: string

Placement ID

loadAsync#

loadAsync(): Promise‹void›

Call signature defined in models/ad-instance.ts:78

Start loading ad. Attempt of loading can sometimes fail for reasons (e.g. ad is not filled, network failure). Game developer can handle each case with a different error handling strategy.

example

// after adInstance is created
adInstance.loadAsync();

Returns: Promise‹void›

showAsync#

showAsync(): Promise‹void›

Call signature defined in models/ad-instance.ts:96

Show the loaded ad to player. The returned promise will be only resolved when user fully watched this ad. The attempt of showing can sometimes fail for reasons (e.g. user skipped the ad or network failure). Game developer can handle each case with a different error handling strategy.

example

// after adInstance is loaded
adInstance.showAsync();

Returns: Promise‹void›

RewardedVideoInstance#

RewardedVideoInstance:

Class defined in models/ad-instance.ts:103

Methods

getPlacementID#

getPlacementID(): string

Call signature defined in models/ad-instance.ts:45

Get the ad's placement ID.

example

adInstance.getPlacementID() // '5458282176661711'

Returns: string

Placement ID

loadAsync#

loadAsync(): Promise‹void›

Call signature defined in models/ad-instance.ts:122

Start loading ad. Attempt of loading can sometimes fail for reasons (e.g. ad is not filled, network failure). Game developer can handle each case with a different error handling strategy.

example

// after adInstance is created
adInstance.loadAsync();

Returns: Promise‹void›

showAsync#

showAsync(): Promise‹void›

Call signature defined in models/ad-instance.ts:140

Show the loaded ad to player. The returned promise will be only resolved when user fully watched this ad. The attempt of showing can sometimes fail for reasons (e.g. user skipped the ad or network failure). Game developer can handle each case with a different error handling strategy.

example

// after adInstance is loaded
adInstance.showAsync();

Returns: Promise‹void›


Classes

ConnectedPlayer#

ConnectedPlayer:

Class defined in models/connected-player.ts:7

Representing a connected player.

Methods

getID#

getID(): string

Call signature defined in models/player.ts:29

Get the player's ID.

example

player.getID(); // '5458282176661711'

Returns: string

Player ID

getName#

getName(): string

Call signature defined in models/player.ts:41

Get the player's name.

example

player.getName(); // 'Alpha Omega'

Returns: string

Player name

getPhoto#

getPhoto(): string

Call signature defined in models/player.ts:55

Get the player's photo.

example

player.getPhoto(); // A CORS supported URL to user's photo

Returns: string

URL of player photo

hasPlayed#

hasPlayed(): boolean

Call signature defined in models/player.ts:67

Get info about if the player has played the game.

example

player.hasPlayed();

Returns: boolean

True if the player has played the game


Classes

ContextPlayer#

ContextPlayer:

Class defined in models/context-player.ts:7

Representing a context player.

Methods

getID#

getID(): string

Call signature defined in models/player.ts:29

Get the player's ID.

example

player.getID(); // '5458282176661711'

Returns: string

Player ID

getName#

getName(): string

Call signature defined in models/player.ts:41

Get the player's name.

example

player.getName(); // 'Alpha Omega'

Returns: string

Player name

getPhoto#

getPhoto(): string

Call signature defined in models/player.ts:55

Get the player's photo.

example

player.getPhoto(); // A CORS supported URL to user's photo

Returns: string

URL of player photo

hasPlayed#

hasPlayed(): boolean

Call signature defined in models/player.ts:67

Get info about if the player has played the game.

example

player.hasPlayed();

Returns: boolean

True if the player has played the game


Classes

Leaderboard#

Leaderboard:

Class defined in models/leaderboard.ts:24

Representing a leaderboard. Can be retrieved by calling LinkGame.getLeaderboardAsync().

Methods

getConnectedPlayerEntriesAsync#

getConnectedPlayerEntriesAsync(count: number, offset: number): Promise‹LeaderboardEntry[]›

Call signature defined in models/leaderboard.ts:194

Get a list of connected player entries inside the leaderboard based on the count and rank offset specified

Experimental support: please note that this API is subject to breaking change.

example

// Get top 10 friend entries
leaderboard.getConnectedPlayerEntriesAsync(10, 0)
.then((entries) => {
console.log(entries.length) // 10 if there're >= 10 friend entries
})

Parameters:

NameTypeDescription
countnumberThe number of maximum entries to be retruned
offsetnumberThe offset in the leaderborad (from the top) the entries to be returned

Returns: Promise‹LeaderboardEntry[]›

Array of entry info

getContextID#

getContextID(): null

Call signature defined in models/leaderboard.ts:65

Get ID of the context which the leaderboard belongs to. Since Link Game Platform doesn't support contextual leaderboard, this method will only return null.

example

LinkGame.getLeaderboardAsync('global_leaderboard')
.then((leaderboard) => {
leaderboard.getContextId() // null
})

Returns: null

Related context ID

getEntriesAsync#

getEntriesAsync(count: number, offset: number): Promise‹LeaderboardEntry[]›

Call signature defined in models/leaderboard.ts:167

Get a list of entries inside the leaderboard based on the count and rank offset specified. Since only friends' entries will be returned, this is effectively the same method as Leaderboard.getConnectedPlayerEntriesAsync()

Experimental support: please note that this API is subject to breaking change.

example

// Get top 10 entries
leaderboard.getEntriesAsync(10, 0)
.then((entries) => {
console.log(entries.length) // 10 if there're >= 10 entries
})

Parameters:

NameTypeDescription
countnumberThe number of maximum entries to be retruned
offsetnumberThe offset in the leaderborad (from the top) the entries to be returned

Returns: Promise‹LeaderboardEntry[]›

Array of entry info

getEntryCountAsync#

getEntryCountAsync(): Promise‹number›

Call signature defined in models/leaderboard.ts:84

Get total number of visible entries inside the leaderboard.

Experimental support: please note that this API is subject to breaking change.

example

LinkGame.getLeaderboardAsync('global_leaderboard')
.then((leaderboard) => {
leaderboard.getEntryCountAsync().then((count) => {
console.log('count: ', count) // count: 2
})
})

Returns: Promise‹number›

Total number of entries

getName#

getName(): string

Call signature defined in models/leaderboard.ts:48

Get the leaderboard's name.

example

LinkGame.getLeaderboardAsync('global_leaderboard')
.then((leaderboard) => {
leaderboard.getName() // 'global_leaderboard'
})

Returns: string

Leaderboard name

getPlayerEntryAsync#

getPlayerEntryAsync(): Promise‹LeaderboardEntry | null›

Call signature defined in models/leaderboard.ts:138

Get current player's entry. Returns null if there isn't one.

Experimental support: please note that this API is subject to breaking change.

example

leaderboard.getPlayerEntryAsync()
.then((entry) => {
if (!entry) {
console.log('No player entry found')
return
}
entry.getScore() // 100
})

Returns: Promise‹LeaderboardEntry | null›

Entry info

setScoreAsync#

setScoreAsync(score: number, extraData?: undefined | string): Promise‹LeaderboardEntry

Call signature defined in models/leaderboard.ts:110

Submit score to the leaderboard and get the latest entry. A player can only have one entry. If there's already an old entry, it will be only updated to the a better score.

Experimental support: please note that this API is subject to breaking change.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getScore() // 100
})

Parameters:

NameTypeDescription
scorenumberThe new score
extraData?undefined | stringA string payload can be attached to the entry as extra info

Returns: Promise‹LeaderboardEntry

Entry info


Classes

LeaderboardEntry#

LeaderboardEntry:

Class defined in models/leaderboard-entry.ts:9

Represent a leaderboard entry. An entry is created when a player submit score to the leaderboard for the first time. After creation, the entry will be only updated when a better score is submit by this player.

Methods

getExtraData#

getExtraData(): string | null

Call signature defined in models/leaderboard-entry.ts:110

Get the extra data submit with the last update. Returns null if no extra data exists.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getExtraData() // 'Hello world'
})

Returns: string | null

Extra data appended with last update or creation

getFormattedScore#

getFormattedScore(): string

Call signature defined in models/leaderboard-entry.ts:62

Get the formatted score of this entry. Format is based on the leaderboard's setting.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getFormattedScore() // '100pt'
})

Returns: string

Formatted score

getPlayer#

getPlayer(): LeaderboardPlayer

Call signature defined in models/leaderboard-entry.ts:125

Get the player's info of this entry.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getPlayer().getID() // '5458282176661711'
})

Returns: LeaderboardPlayer

Player's info

getRank#

getRank(): number

Call signature defined in models/leaderboard-entry.ts:94

Get the rank of this player. It's calculated based on the entry's score and the leaderboard's sort setting.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getRank() // 2
})

Returns: number

Rank

getScore#

getScore(): number

Call signature defined in models/leaderboard-entry.ts:46

Get the score of this entry.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getScore() // 100
})

Returns: number

Score

getTimestamp#

getTimestamp(): number

Call signature defined in models/leaderboard-entry.ts:78

Get the timestamp of when the entry is updated or created for the last time.

example

leaderboard.setScoreAsync(100, 'Hello world')
.then((entry) => {
entry.getTimestamp() // 1527810893
})

Returns: number

Timestamp of last update or creation


Classes

LeaderboardPlayer#

LeaderboardPlayer:

Class defined in models/leaderboard-player.ts:7

Representing a leaderboard player.

Methods

getID#

getID(): string

Call signature defined in models/player.ts:29

Get the player's ID.

example

player.getID(); // '5458282176661711'

Returns: string

Player ID

getName#

getName(): string

Call signature defined in models/player.ts:41

Get the player's name.

example

player.getName(); // 'Alpha Omega'

Returns: string

Player name

getPhoto#

getPhoto(): string

Call signature defined in models/player.ts:55

Get the player's photo.

example

player.getPhoto(); // A CORS supported URL to user's photo

Returns: string

URL of player photo

hasPlayed#

hasPlayed(): true

Call signature defined in models/leaderboard-player.ts:12

Get info about if the player has played the game.

Returns: true

Always true


Classes

SignedPlayerInfo#

SignedPlayerInfo:

Class defined in models/signed-player-info.ts:9

Represents player info in a secure way, encrypted by the server side of the platform hosting the game. Game server can decrypt this info on to verify if this is data is really sent from the platform.

Methods

getPlayerID#

getPlayerID(): string

Call signature defined in models/signed-player-info.ts:32

Get the player's ID

example

LinkGame.player.getSignedPlayerInfoAsync('some_metadata')
.then(function (result) {
result.getPlayerID(), // same value as LinkGame.player.getID()
})

Returns: string

Player ID

getSignature#

getSignature(): Signature

Call signature defined in models/signed-player-info.ts:47

Get the signature string

example

LinkGame.player.getSignedPlayerInfoAsync('some_metadata')
.then(function (result) {
result.getSignature() // some string like this, 'S0M3_5igNatvR3.eyJpc3N1ZWRfYXQiOiAxNTM5OTMxNDQ2LCAicGxheWVyX2lkIjogIjgwZDU4N2UyODkzNjdlNTVhZjRhNGQ0OTIyOThkNmRkNDdjMGFiYmMyMjc1YjNjMDQ0ODkyMTY2ZGE3MzM5NmYiLCAiYWxnb3JpdGhtIjogIkhNQUMtU0hBMjU2IiwgInJlcXVlc3RfcGF5bG9hZCI6ICJteV9tZXRhZGF0YSJ9'
})

Returns: Signature

Signature of player info


Interfaces

AdUnit#

AdUnit:

Interface defined in types/ad-instance.ts:7

Properties

id: string

Property defined in types/ad-instance.ts:9

type: "INTERSTITIAL" | "REWARDED_VIDEO"

Property defined in types/ad-instance.ts:8


Type aliases

GetAdUnitsResponse#

GetAdUnitsResponse: AdUnit[]

Type alias defined in types/bridge.ts:150


Interfaces

ContextChoosePayload#

ContextChoosePayload:

Interface defined in types/context.ts:6

Properties

caption? : string | LocalizableContent

Property defined in types/message-options.ts:20

Text of the call to action button. If not specified, "今すぐプレイ" will be used by default.

data? : Record‹string, unknown›

Property defined in types/message-options.ts:26

Object passed to any session launched from this update message. It can be accessed from LinkGame.getEntryPointData(). Its size must be <=1000 chars when stringified.

image? : undefined | string

Property defined in types/message-options.ts:10

Image which will be displayed to contact. A string containing data URL of a base64 encoded image. If not specified, game's icon image will be used by default.

text? : string | LocalizableContent

Property defined in types/message-options.ts:15

Message which will be displayed to contact. If not specified, "{{senderName}}と一緒に「{{gameName}}」をプレイしよう!" will be used by default.

ContextCreatePayload#

ContextCreatePayload:

Interface defined in types/context.ts:32

Properties

caption? : string | LocalizableContent

Property defined in types/context.ts:43

Text of the call to action button. If not specified, "プレイ" will be used by default.

text? : string | LocalizableContent

Property defined in types/context.ts:38

Message which will be displayed to contact. {{gameName}}, {{senderName}}, {{receiverName}} can be used as template string in the text. If not specified, "{{receiverName}}\nとプレイしますか?" will be used by default.


Interfaces

InitializationOptions#

InitializationOptions:

Interface defined in types/initialization.ts:1

Properties

scrollTarget? : string | Element

Property defined in types/initialization.ts:7

By default, scrolling will be locked in game frame to prevent unexpected behavior (e.g. scroll while flicking). If scrolling is needed, set an element (or its selector) here, then the element (including its children) will be scrollable. If scrolling lock needs to be disabled, set document.body here.


Type aliases

Platform#

Platform: "IOS" | "ANDROID" | "DESKTOP"

Type alias defined in types/platform.ts:4

The underlying platform where Link app is running on.


Interfaces

SharePayload#

SharePayload:

Interface defined in types/share-payload.ts:3

Properties

caption? : string | LocalizableContent

Property defined in types/message-options.ts:20

Text of the call to action button. If not specified, "今すぐプレイ" will be used by default.

data? : Record‹string, unknown›

Property defined in types/message-options.ts:26

Object passed to any session launched from this update message. It can be accessed from LinkGame.getEntryPointData(). Its size must be <=1000 chars when stringified.

image? : undefined | string

Property defined in types/message-options.ts:10

Image which will be displayed to contact. A string containing data URL of a base64 encoded image. If not specified, game's icon image will be used by default.

text? : string | LocalizableContent

Property defined in types/message-options.ts:15

Message which will be displayed to contact. If not specified, "{{senderName}}と一緒に「{{gameName}}」をプレイしよう!" will be used by default.


Type aliases

Signature#

Signature: string

Type alias defined in types/signature.ts:11

A signature that can be verified on game's backend server. Server side validation can be done by following these steps:

  1. Split the signature into two parts delimited by the . character.
  2. Decode the first part with base64url encoding, which should be a hash.
  3. Decode the second part with base64url encoding, which should be a string representation of an JSON object.
  4. Hash the second part string using HMAC SHA-256 and the app secret, check if it is identical to the hash from step 2.
  5. Optionally, developer can also validate the timestamp to see if the request is made recently.