FAPI.UI.showInvite

General information

Displays the user invitation dialog. Allows specifying a default invitation text and application custom arguments.

Unlike showNotification method it does not allow sending invitations to users who have been using this app.

Method signature

FAPI.UI.showInvite(text, params, selected_uids);
ParameterRequiredDescription
textYesText that will be sent in the invitation
paramsNoCustom data transmitted to the application when a user accepts the invitation. The data will be transmitted in the custom_args parameter. For more information, see application parameters.
Max length: 120 characters.
selected_uidsNoThe list of friend IDs that will already be selected when the invitation window opens.
20 IDs per request max.
Users must be in the friend list. Friends selected are only those who have been playing games recently.

Example usage

function showInvite() {
    FAPI.UI.showInvite("Play in my game!", "arg1=val1");
}

Example using selected_uids parameter

function showInvite() {
    var callback = function(status, result, data) {
        if(result.length > 0) {
            FAPI.UI.showInvite("Play in my game!", "arg1=val1", result[0]);
        } else {
            alert("Not enough friends for using example");
        }
    }
    FAPI.Client.call({"method":"friends.get"}, callback);
}

Callback example

Following values can be passed as API_callback function arguments:

Callback if user declined to send an invite

Web

method: “showInvite”

result: “cancel”

data: “null”

Mobile

method: “showInvite”

result: “error”

data: “cancel”

Callback if user sent an invite to a single friend

method: “showInvite”

result: “ok”

data: “1234567890”

Callback if user sent an invite to multiple friends at once

method: “showInvite”

result: “ok”

data: “1234567890,1234567891”

Callback if no available friends to invite were found (mobile only)

method: “showInvite”

result: “error”

data: “noUsers”

Dialog example

A dialog where user can select friends to invite will be displayed as a result:

Dialog example on web

Dialog example on mobile