Overview
GamingContext represents a game instance—either a solo game or a multiplayer session. The SDK maintains a current singleton that reflects the active context. You do not create a GamingContext directly in most cases; instead, the SDK sets GamingContext.current when the user enters a context via a context dialog (such as SwitchContextDialog or CreateContextDialog).
Module: FacebookGamingServicesDeclared in:
GamingContext.swiftObjective-C name:
FBSDKGamingContext
Initializer
A non-empty unique identifier for the context. Returns
nil if the identifier is empty.The number of players in the game instance. Negative values are clamped to
0.Properties
A class-level (static) property holding the current game context. It is
nil when no context is active. Objective-C name: currentContext.A unique identifier for the current game instance. Read-only.
The number of players in the current game instance. Always
>= 0. Read-only.How the context is set
TheGamingContext.current property is populated automatically when the user switches to or creates a game context using the Gaming Services context dialogs:
SwitchContextDialog— switches to an existing context selected by the user.CreateContextDialog— creates a new context with a specific player.ChooseContextDialog— lets the user pick from a list of available contexts.
GamingContext with the returned identifier and size and assigns it to GamingContext.current.