Difference between revisions of "FBInstant.context.chooseAsync"
From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2018.3<br/> === Description === <br /> Opens a context selection dialog for the player. If the player selects an available context, th...") |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(8 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Available since:''' Gideros 2018.3<br/> | + | <languages /> |
− | === Description === | + | '''<translate>Available since</translate>:''' Gideros 2018.3<br/> |
− | <br /> | + | '''<translate>Class</translate>:''' [[Special:MyLanguage/Context|Context]]<br/> |
+ | === <translate>Description</translate> === | ||
+ | <translate><br /> | ||
Opens a context selection dialog for the player. If the player selects an available context, the client will attempt to switch into that context, and resolve if successful. Otherwise, if the player exits the menu or the client fails to switch into the new context, this function will reject.<br /> | Opens a context selection dialog for the player. If the player selects an available context, the client will attempt to switch into that context, and resolve if successful. Otherwise, if the player exits the menu or the client fails to switch into the new context, this function will reject.<br /> | ||
− | <br /> | + | <br /></translate> |
− | < | + | <syntaxhighlight lang="lua"> |
− | + | FBInstant.context.chooseAsync(options,callback) | |
− | </ | + | </syntaxhighlight> |
− | '''options | + | === <translate>Parameters</translate> === |
− | '''callback | + | '''options''': (table) <translate>A table specifying conditions on the contexts that should be offered.</translate> '''optional'''<br/> |
+ | '''callback''': (function) <translate>A function that will be called with two arguments: true when the game has switched into the context chosen by the user. Otherwise, the promise will reject (if the user cancels out of the dialog, for example) and an error code if the function failed.</translate> <br/> | ||
+ | === <translate>Examples</translate> === | ||
+ | '''Example'''<br/> | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | print(FBInstant.context.getID()) -- eg returns 1122334455 | ||
+ | FBInstant.context.chooseAsync(nil, function(result,error) | ||
+ | if result then | ||
+ | print(FBInstant.context.getID()) -- eg returns 1234567890 | ||
+ | end | ||
+ | end) | ||
+ | <br/></syntaxhighlight> | ||
+ | '''Example 2'''<br/> | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | print(FBInstant.context.getID()) -- eg returns 1122334455 | ||
+ | -- A filter that may be applied to a Context Choose operation: | ||
+ | -- 'NEW_CONTEXT_ONLY' - Prefer to only surface contexts the game has not been played in before. | ||
+ | -- 'INCLUDE_EXISTING_CHALLENGES' - Include the "Existing Challenges" section, which surfaces actively played-in contexts that the player is a part of. | ||
+ | -- 'NEW_PLAYERS_ONLY' - In sections containing individuals, prefer people who have not played the game. | ||
+ | FBInstant.context.chooseAsync({filters={"NEW_CONTENT_ONLY"},minSize=3,maxSize=5}, function(result,error) | ||
+ | if result then | ||
+ | print(FBInstant.context.getID()) -- eg returns 1234567890 | ||
+ | end | ||
+ | end) | ||
+ | <br/></syntaxhighlight> | ||
+ | |||
+ | {{FBInstant.context}} |
Latest revision as of 14:26, 13 July 2023
Available since: Gideros 2018.3
Class: Context
Description
Opens a context selection dialog for the player. If the player selects an available context, the client will attempt to switch into that context, and resolve if successful. Otherwise, if the player exits the menu or the client fails to switch into the new context, this function will reject.
FBInstant.context.chooseAsync(options,callback)
Parameters
options: (table) A table specifying conditions on the contexts that should be offered. optional
callback: (function) A function that will be called with two arguments: true when the game has switched into the context chosen by the user. Otherwise, the promise will reject (if the user cancels out of the dialog, for example) and an error code if the function failed.
Examples
Example
print(FBInstant.context.getID()) -- eg returns 1122334455
FBInstant.context.chooseAsync(nil, function(result,error)
if result then
print(FBInstant.context.getID()) -- eg returns 1234567890
end
end)
<br/>
Example 2
print(FBInstant.context.getID()) -- eg returns 1122334455
-- A filter that may be applied to a Context Choose operation:
-- 'NEW_CONTEXT_ONLY' - Prefer to only surface contexts the game has not been played in before.
-- 'INCLUDE_EXISTING_CHALLENGES' - Include the "Existing Challenges" section, which surfaces actively played-in contexts that the player is a part of.
-- 'NEW_PLAYERS_ONLY' - In sections containing individuals, prefer people who have not played the game.
FBInstant.context.chooseAsync({filters={"NEW_CONTENT_ONLY"},minSize=3,maxSize=5}, function(result,error)
if result then
print(FBInstant.context.getID()) -- eg returns 1234567890
end
end)
<br/>