General information

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

A notification is similar to an invite, except that it can be sent to users who are already using the application.

Method signature

FAPI.UI.showNotification(text, params, selected_uids);
ParameterRequiredDescription
textYesText that will be sent in the notification
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.

Restrictions

Notifications are restricted to 40 per day per one user. Before calling the method, you can check the restriction with the users.getCallsLeft method, indicating the special constant notifications.sendFromUser.

Example usage

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

Example using selected_uids parameter

function showNotification(){
    var callback = function(status, result, data){
        if(result.length > 2){
            FAPI.UI.showNotification("Play in my game!", "arg1=val1", result[0] + ";" + result[1]);
        } 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 a notification

Web

method: “showNotification”

result: “cancel”

data: “null”

Mobile

method: “showNotification”

result: “error”

data: “cancel”

Callback if user sent a notification to a single friend

method: “showNotification”

result: “ok”

data: “1234567890”

Callback if user sent a notification to multiple friends at once

method: “showNotification”

result: “ok”

data: “1234567890,1234567891”

Callback if no available friends to sent a notification were found (mobile only)

method: “showNotification”

result: “error”

data: “noUsers”

Dialog example

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

Dialog example on web

Dialog example on mobile