API Reference
Variables
Functions
#
LinkGame.getAdUnitsAsyncgetAdUnitsAsync(): 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
Returns: Promise‹AdUnit[]›
#
LinkGame.getEntryPointAsyncgetEntryPointAsync(): Promise‹string›
Call signature defined in sdk/index.ts:488
Get information about where the game is started.
example
Returns: Promise‹string›
#
LinkGame.getEntryPointDatagetEntryPointData(): EntryPointData
Call signature defined in sdk/index.ts:249
Get the entry point data bound to the entry point.
example
Returns: EntryPointData
#
LinkGame.getInterstitialAdAsyncgetInterstitialAdAsync(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
Parameters:
Name | Type |
---|---|
placementId | string |
Returns: Promise‹InterstitialAdInstance›
#
LinkGame.getLeaderboardAsyncgetLeaderboardAsync(name
: string): Promise‹Leaderboard›
Call signature defined in sdk/index.ts:334
Get a leaderboard by its name
example
Parameters:
Name | Type | Description |
---|---|---|
name | string | The name of the leaderboard |
Returns: Promise‹Leaderboard›
#
LinkGame.getLocalegetLocale(): 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
Returns: string
#
LinkGame.getPlatformgetPlatform(): Platform
Call signature defined in sdk/index.ts:500
Get information about from which platform the game is started, regarding OS or browser.
example
Returns: Platform
#
LinkGame.getRewardedVideoAsyncgetRewardedVideoAsync(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
Parameters:
Name | Type |
---|---|
placementId | string |
Returns: Promise‹RewardedVideoInstance›
#
LinkGame.getTrafficSourcegetTrafficSource(): 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
Returns: TrafficSource
#
LinkGame.initializeAsyncinitializeAsync(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
Parameters:
Name | Type | Default | Description |
---|---|---|---|
options | InitializationOptions | {} | Extra options to alter the runtime behavior of the SDK. |
Returns: Promise‹void›
#
LinkGame.onPauseonPause(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
Parameters:
▪ fn: function
(): void
Returns: void
#
LinkGame.openDeeplinkAsyncopenDeeplinkAsync(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
Parameters:
Name | Type |
---|---|
category | string |
params | string |
Returns: Promise‹void›
#
LinkGame.openUrlAsyncopenUrlAsync(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
Parameters:
Name | Type |
---|---|
url | string |
Returns: Promise‹void›
#
LinkGame.setLoadingProgresssetLoadingProgress(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
Parameters:
Name | Type | Default | Description |
---|---|---|---|
percentage | number | 0 | Represents percentage of loading progress. It should be between 0 and 100. |
Returns: void
#
LinkGame.shareAsyncshareAsync(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
Parameters:
Name | Type | Description |
---|---|---|
payload | SharePayload | An object describes the message to be shared. |
Returns: Promise‹ShareResult›
#
LinkGame.startGameAsyncstartGameAsync(): 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
Returns: Promise‹void›
#
LinkGame.updateAsyncupdateAsync(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
Parameters:
Name | Type | Description |
---|---|---|
payload | CustomUpdatePayload | An object describes the update message |
Returns: Promise‹void›
Functions
#
LinkGame.context.chooseAsyncchooseAsync(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
Parameters:
Name | Type | Description |
---|---|---|
payload | ContextChoosePayload | Additional parameters for the UI |
Returns: Promise‹void›
#
LinkGame.context.createAsynccreateAsync(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
Parameters:
Name | Type | Default | Description |
---|---|---|---|
playerId | string | - | Player ID of the opponent player |
payload | ContextCreatePayload | {} | Additional parameters for main text and action button on the popup UI |
Returns: Promise‹void›
#
LinkGame.context.getIDgetID(): string | null
Call signature defined in sdk/context.ts:28
Get ID of current context
example
Returns: string | null
#
LinkGame.context.getPlayersAsyncgetPlayersAsync(): 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
Returns: Promise‹ContextPlayer[]›
#
LinkGame.context.getTypegetType(): "SOLO" | "THREAD"
Call signature defined in sdk/context.ts:40
Get type of current context
example
Returns: "SOLO" | "THREAD"
#
LinkGame.context.isSizeBetweenisSizeBetween(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
Parameters:
Name | Type | Description |
---|---|---|
minSize? | undefined | number | The minimum boundry of the check |
maxSize? | undefined | number | The maximum boundry of the check |
Returns: ContextSizeResponse | null
#
LinkGame.context.switchAsyncswitchAsync(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
Parameters:
Name | Type | Default | Description |
---|---|---|---|
contextId | string | - | Context ID of the context |
payload | ContextCreatePayload | {} | Additional parameters for main text and action button on the popup UI |
Returns: Promise‹void›
Functions
#
LinkGame.player.flushDataAsyncflushDataAsync(): Promise‹void›
Call signature defined in sdk/player.ts:85
Will flush any unsaved data to platform storage
Returns: Promise‹void›
#
LinkGame.player.getConnectedPlayersAsyncgetConnectedPlayersAsync(): 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
Returns: Promise‹Array‹ConnectedPlayer››
Array of connected players
#
LinkGame.player.getDataAsyncgetDataAsync(keys
: string[]): Promise‹PlayerData›
Call signature defined in sdk/player.ts:34
Get game data from platform storage.
example
Parameters:
Name | Type | Description |
---|---|---|
keys | string[] | An array of unique keys to retrieve data for. |
Returns: Promise‹PlayerData›
Latest snapshot of game data
#
LinkGame.player.getIDgetID(): string | null
Call signature defined in sdk/player.ts:97
Get the player's ID.
example
Returns: string | null
Player's ID
#
LinkGame.player.getNamegetName(): string | null
Call signature defined in sdk/player.ts:109
Get the player's name.
example
Returns: string | null
Player's name
#
LinkGame.player.getPhotogetPhoto(): string | null
Call signature defined in sdk/player.ts:123
Get the player's photo.
example
Returns: string | null
URL of player photo
#
LinkGame.player.getSignedPlayerInfoAsyncgetSignedPlayerInfoAsync(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
Parameters:
Name | Type | Description |
---|---|---|
payload? | undefined | string | An arbitary string to be signed |
Returns: Promise‹SignedPlayerInfo›
An object containing signed player info and custom payload
#
LinkGame.player.hasPlayedhasPlayed(): boolean
Call signature defined in sdk/player.ts:135
Get info about if the player has played the game.
example
Returns: boolean
Always true
#
LinkGame.player.setDataAsyncsetDataAsync(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
Parameters:
Name | Type | Description |
---|---|---|
data | Record‹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
#
InterstitialAdInstanceInterstitialAdInstance:
Class defined in models/ad-instance.ts:59
Methods
#
getPlacementIDgetPlacementID(): string
Call signature defined in models/ad-instance.ts:45
Get the ad's placement ID.
example
Returns: string
Placement ID
#
loadAsyncloadAsync(): 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
Returns: Promise‹void›
#
showAsyncshowAsync(): 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
Returns: Promise‹void›
#
RewardedVideoInstanceRewardedVideoInstance:
Class defined in models/ad-instance.ts:103
Methods
#
getPlacementIDgetPlacementID(): string
Call signature defined in models/ad-instance.ts:45
Get the ad's placement ID.
example
Returns: string
Placement ID
#
loadAsyncloadAsync(): 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
Returns: Promise‹void›
#
showAsyncshowAsync(): 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
Returns: Promise‹void›
Classes
#
ConnectedPlayerConnectedPlayer:
Class defined in models/connected-player.ts:7
Representing a connected player.
Methods
#
getIDgetID(): string
Call signature defined in models/player.ts:29
Get the player's ID.
example
Returns: string
Player ID
#
getNamegetName(): string
Call signature defined in models/player.ts:41
Get the player's name.
example
Returns: string
Player name
#
getPhotogetPhoto(): string
Call signature defined in models/player.ts:55
Get the player's photo.
example
Returns: string
URL of player photo
#
hasPlayedhasPlayed(): boolean
Call signature defined in models/player.ts:67
Get info about if the player has played the game.
example
Returns: boolean
True if the player has played the game
Classes
#
ContextPlayerContextPlayer:
Class defined in models/context-player.ts:7
Representing a context player.
Methods
#
getIDgetID(): string
Call signature defined in models/player.ts:29
Get the player's ID.
example
Returns: string
Player ID
#
getNamegetName(): string
Call signature defined in models/player.ts:41
Get the player's name.
example
Returns: string
Player name
#
getPhotogetPhoto(): string
Call signature defined in models/player.ts:55
Get the player's photo.
example
Returns: string
URL of player photo
#
hasPlayedhasPlayed(): boolean
Call signature defined in models/player.ts:67
Get info about if the player has played the game.
example
Returns: boolean
True if the player has played the game
Classes
#
LeaderboardLeaderboard:
Class defined in models/leaderboard.ts:24
Representing a leaderboard. Can be retrieved by calling
LinkGame.getLeaderboardAsync()
.
Methods
#
getConnectedPlayerEntriesAsyncgetConnectedPlayerEntriesAsync(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
Parameters:
Name | Type | Description |
---|---|---|
count | number | The number of maximum entries to be retruned |
offset | number | The offset in the leaderborad (from the top) the entries to be returned |
Returns: Promise‹LeaderboardEntry[]›
Array of entry info
#
getContextIDgetContextID(): 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
Returns: null
Related context ID
#
getEntriesAsyncgetEntriesAsync(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
Parameters:
Name | Type | Description |
---|---|---|
count | number | The number of maximum entries to be retruned |
offset | number | The offset in the leaderborad (from the top) the entries to be returned |
Returns: Promise‹LeaderboardEntry[]›
Array of entry info
#
getEntryCountAsyncgetEntryCountAsync(): 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
Returns: Promise‹number›
Total number of entries
#
getNamegetName(): string
Call signature defined in models/leaderboard.ts:48
Get the leaderboard's name.
example
Returns: string
Leaderboard name
#
getPlayerEntryAsyncgetPlayerEntryAsync(): 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
Returns: Promise‹LeaderboardEntry | null›
Entry info
#
setScoreAsyncsetScoreAsync(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
Parameters:
Name | Type | Description |
---|---|---|
score | number | The new score |
extraData? | undefined | string | A string payload can be attached to the entry as extra info |
Returns: Promise‹LeaderboardEntry›
Entry info
Classes
#
LeaderboardEntryLeaderboardEntry:
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
#
getExtraDatagetExtraData(): 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
Returns: string | null
Extra data appended with last update or creation
#
getFormattedScoregetFormattedScore(): 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
Returns: string
Formatted score
#
getPlayergetPlayer(): LeaderboardPlayer
Call signature defined in models/leaderboard-entry.ts:125
Get the player's info of this entry.
example
Returns: LeaderboardPlayer
Player's info
#
getRankgetRank(): 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
Returns: number
Rank
#
getScoregetScore(): number
Call signature defined in models/leaderboard-entry.ts:46
Get the score of this entry.
example
Returns: number
Score
#
getTimestampgetTimestamp(): 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
Returns: number
Timestamp of last update or creation
Classes
#
LeaderboardPlayerLeaderboardPlayer:
Class defined in models/leaderboard-player.ts:7
Representing a leaderboard player.
Methods
#
getIDgetID(): string
Call signature defined in models/player.ts:29
Get the player's ID.
example
Returns: string
Player ID
#
getNamegetName(): string
Call signature defined in models/player.ts:41
Get the player's name.
example
Returns: string
Player name
#
getPhotogetPhoto(): string
Call signature defined in models/player.ts:55
Get the player's photo.
example
Returns: string
URL of player photo
#
hasPlayedhasPlayed(): 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
#
SignedPlayerInfoSignedPlayerInfo:
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
#
getPlayerIDgetPlayerID(): string
Call signature defined in models/signed-player-info.ts:32
Get the player's ID
example
Returns: string
Player ID
#
getSignaturegetSignature(): Signature
Call signature defined in models/signed-player-info.ts:47
Get the signature string
example
Returns: Signature
Signature of player info
Interfaces
#
AdUnitAdUnit:
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
#
GetAdUnitsResponseGetAdUnitsResponse: AdUnit[]
Type alias defined in types/bridge.ts:150
Interfaces
#
ContextChoosePayloadContextChoosePayload:
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.
#
ContextCreatePayloadContextCreatePayload:
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
#
InitializationOptionsInitializationOptions:
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
#
PlatformPlatform: "IOS" | "ANDROID" | "DESKTOP"
Type alias defined in types/platform.ts:4
The underlying platform where Link app is running on.
Interfaces
#
SharePayloadSharePayload:
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
#
SignatureSignature: 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:
- Split the signature into two parts delimited by the
.
character. - Decode the first part with base64url encoding, which should be a hash.
- Decode the second part with base64url encoding, which should be a string representation of an JSON object.
- Hash the second part string using HMAC SHA-256 and the app secret, check if it is identical to the hash from step 2.
- Optionally, developer can also validate the timestamp to see if the request is made recently.