FB.AppRequest

Prompts the someone using your app to send game requests, short messages between users. Please see the documentation for details.

When called in the Unity Editor, a stub function is called instead.

Parameters

public static void AppRequest(
    string message, 
    OGActionType actionType,
    string objectId,
    IEnumerable<string> to,
    string data = "",
    string title = "",    
    FacebookDelegate<IAppRequestResult> callback = null
)

Name Type Description Default
messagestring

The request string the recipient will see, maximum length 60 characters.

required

actionTypeOGActionType

Request action type for Structured Requests

null

objectIdstring

Open Graph object ID for structured request

null

toIEnumerable<string&gt;

A list of Facebook IDs to which to send the request

none - the sender will be shown a dialog allowing him/her to choose the recipients

datastring

Additional data stored with the request on Facebook, and handed back to the app when it reads the request back out. Maximum length 255 characters.

none

titlestring

The title for the platform multi-friend selector dialog. Max length 50 characters.

'Select friends for

appname

requests' or translated equivalent

callbackFacebookDelegate <IAppRequestResult&gt;

A callback function which will get invoked with the response. If the sender sends any requests, it will receive an JSON dictionary with two properties,

request

(a

string

containing the Request ID assigned by Facebook) and

to

(an array of

string

, each element being the Facebook ID of one of the selected recipients). If the sender doesn't send any requests, it will instead be

null

null

Examples

Allow a player to recommend your game to friends, which he/she will choose from the Facebook-provided friend picker dialog.

FB.AppRequest(
    "Come play this great game!",
    null, null, null, null, null, null,
    delegate (IAppRequestResult result) {
        Debug.Log(result.RawResult);
    }
);

Allow a player to send a game request to friends who also play your game using the Facebook-provided friend picker dialog.

FB.AppRequest(
    "Here is a free gift!",
    null,
    new List<object> (){ "app_users" },
    null, null, null, null,
    delegate (IAppRequestResult result) {
        Debug.Log(result.RawResult);
    }
);

If the player chooses two friends, the callback logs a JSON dictionary of the form

{
    "request": "420211088059698",
    "to": [
        "100002669403922",
        "100000048490273"
    ]
}

The resulting request objects will have the full request IDs 420211088059698_100002669403922 and 420211088059698_100000048490273. See the Game Requests documentation for details.

Best Practices

Consider using this channel whenever you are representing a message sent from a single player to another single player, or to several specific other players. It is a low-noise narrowcast channel, where FB.ShareLink is a broader channel.

Using requests on Facebook, and Facebook notifications, may improve the experience for players playing on more than one platform, when compared to using per-platform push notifications.