Module: context
Table of contents
Functions
Functions
chooseAsync
▸ chooseAsync(payload
): Promise
<void
>
Opens the platform UI to select friends to invite and play with.
Example
Wortal.context.chooseAsync({
image: 'data:base64Image',
text: 'Invite text',
caption: 'Play',
data: { exampleData: 'yourData' },
});
Parameters
Name | Type | Description |
---|---|---|
payload |
ContextPayload |
Object defining the options for the context choice. |
Returns
Promise
<void
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
createAsync
▸ createAsync(playerId
): Promise
<void
>
Creates a context with the given player ID.
Example
Parameters
Name | Type | Description |
---|---|---|
playerId |
string |
ID of player to create a context with. |
Returns
Promise
<void
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getId
▸ getId(): string
Gets the ID of the current context.
Example
Returns
string
String ID of the current context if one exists. Null if the player is playing solo. Empty string if the game is being played on a platform that does not currently support context.
shareAsync
▸ shareAsync(payload
): Promise
<number
>
Shares a message to the player's friends. Will trigger a UI for the player to choose which friends to share with.
Example
Wortal.context.shareAsync({
image: 'data:base64Image',
text: 'Share text',
caption: 'Play',
data: { exampleData: 'yourData' },
}).then(result => console.log(result); // Contains shareCount with number of friends the share was sent to.
Parameters
Name | Type | Description |
---|---|---|
payload |
ContextPayload |
Object defining the share message. |
Returns
Promise
<number
>
Number of friends the message was shared with.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
switchAsync
▸ switchAsync(contextId
): Promise
<void
>
Switches the current context to the context with the given ID.
Example
Parameters
Name | Type | Description |
---|---|---|
contextId |
string |
ID of the context to switch to. |
Returns
Promise
<void
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
updateAsync
▸ updateAsync(payload
): Promise
<void
>
Posts an update to the current context. Will send a message to the chat thread of the current context.
Example
Wortal.context.updateAsync({
image: 'data:base64Image',
text: 'Update text',
caption: 'Play',
data: { exampleData: 'yourData' },
});
Parameters
Name | Type | Description |
---|---|---|
payload |
ContextPayload |
Object defining the update message. |
Returns
Promise
<void
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM