Overview
GameRequestDialog lets users invite or challenge Facebook friends from within your game. You configure a GameRequestContent object describing the request and present the dialog. The SDK handles both web-based and native (Gaming Services deep link) presentation automatically.
Module: FacebookGamingServicesDeclared in:
GameRequestDialog.swiftObjective-C name:
FBSDKGameRequestDialog
Initializer
init(content:delegate:)
The content describing the game request. See
GameRequestContent below.A weak delegate that receives completion, failure, and cancellation callbacks.
Static factory methods
GameRequestDialog.dialog(content:delegate:)
Creates but does not show a GameRequestDialog.
GameRequestDialog.show(content:delegate:)
Creates and immediately shows a GameRequestDialog.
Properties
The game request content. You can update this before calling
show().The delegate receiving dialog events. Weak reference.
When
true, requests to friends who have previously accepted frictionless requests are sent without showing the dialog. Defaults to false.Always returns
true for GameRequestDialog. Use validate() to check content validity before showing.Methods
show()
Presents the game request dialog.
true if the dialog was presented, false if validation failed.validate()
Validates the content on the receiver. Throws if the content is invalid.
GameRequestContent
GameRequestContent describes the request to send.
Objective-C name: FBSDKGameRequestContent
Properties
The plain-text message to send as part of the request. Required. Defaults to an empty string.
Additional context about the nature of the request. Defaults to
.none. When set to .send or .askFor, you must also provide a non-empty objectID.Controls which friends appear in the multi-friend selector. Defaults to
.none (all friends). Cannot be combined with recipients or recipientSuggestions.An array of user IDs, usernames, or invite tokens specifying the target recipients. When set, the sender cannot choose recipients. Cannot be combined with
filters or recipientSuggestions.User IDs to pre-populate as suggested friends in the multi-friend selector. Cannot be combined with
recipients or filters.Freeform data stored with the request object, up to 255 characters. Use this to pass game-specific state.
The title shown in the game request dialog. Defaults to an empty string.
The Open Graph object ID for
.send and .askFor action types. Defaults to an empty string.The call-to-action text shown in the dialog. Defaults to an empty string.
GameRequestActionType enum
| Case | Description |
|---|---|
.none | No specific action type (default). |
.send | The user is sending an in-game object to friends. Requires objectID. |
.askFor | The user is requesting an in-game object from friends. Requires objectID. |
.turn | Notifies friends that it is their turn in a match. |
.invite | The user is inviting a friend to the game. |
GameRequestFilter enum
| Case | Description |
|---|---|
.none | All friends can be shown in the selector (default). |
.appUsers | Only friends who already use the app are shown. |
.appNonUsers | Only friends who do not use the app are shown. |
.everybody | All friends are shown when the Facebook app is installed. |
GameRequestDialogDelegate protocol
Objective-C name: FBSDKGameRequestDialogDelegate
gameRequestDialog(_:didCompleteWithResults:)
Called when the request is sent successfully.
A dictionary containing the request ID and recipients. Keys include
request_id and recipients.