Rooms Co-Play API Reference

Keep in mind that many standard Instant Game features are not available in a Room environment, including the following: Monetization APIs, Context changing APIs, Game Switch API, Custom Updates API, Custom Sharing API, Create Shortcut API.

FBInstant

Top level namespace for the Instant Games SDK.


room

Contains functions and properties related to the current room.


getCurrentMatchAsync()

Retrieves the current real-time match for the gameplay environment, if one exists.

Examples

FBInstant.room.getCurrentMatchAsync()
  .then(function(match) {
    ...
});
  • Returns Promise<LiveMatch>: This Promise will resolve with a Live Match object if one is present for the current environment, or reject with a relevant error code if there is no current Live Match for the player or environment.

LiveMatch

An instant game live match that is played in a Messenger Rooms call simultaneously by all the participants.


getID()

The unique live match ID.

Examples

FBInstant.room.getCurrentMatchAsync()
  .then(function(match) {
    console.log(match.getID());
});

Returns string: The unique live match ID.


getContextID()

Gets the unique context ID that is associated with this live match.

Examples

FBInstant.room.getCurrentMatchAsync()
  .then(function(match) {
    console.log(match.getContextID());
});

Returns string: The context ID for this live match.


getStatusAsync()

Gets the current status of the live match, for example: PENDING, ABANDONED, CONCLUDED, RUNNING.

Examples

FBInstant.room.getCurrentMatchAsync()
  .then(function(match) {
    match.getStatusAsync().then(status => console.log(status));
});

Returns Promise<LiveMatchStatusType>: A promise of the current state of the Live Match on the platform (e.g. one of the Match State values enumerated above)


getActiveParticipantsAsync()

Retrieves a list of players currently active in the match.

Examples

FBInstant.room.getCurrentMatchAsync()
  .then(function(match) {
    match.getActiveParticipantsAsync().then(activeParticipants => GameMatch.updatePlayers(activeParticipants))
});

Returns Promise<Array<LiveMatchPlayer>>: A promise that resolves with a list of live match player objects.

LiveMatchPlayer

Represents information about a player who is a participant in a real-time match.


getID()

Gets the ID of the live match player.

Returns string: The ID of the live match player.


getName()

Gets the player's display name.

Returns string: The player's display name.


getPhoto()

Gets the player's public profile photo.

Returns string: A URL to the player's public profile photo