Social API Reference #
This section provides references for methods and events in the Pragma Social APIs for Unreal and Unity. For information on Pragma Engine backend classes and plugins, see Social Backend Reference.
Pragma provides the following APIs that developers can use to facilitate social-related processes:
API | used by | example tasks |
---|---|---|
FriendApi | Player client | Send a friend request |
PresenceApi | Player client | Set rich presence value |
Friend API #
The table below contains a list of the API methods relevant to the Friend service. These methods are available via the FriendApi
.
Methods #
method | description |
---|---|
AcceptFriendInvite() | Accepts a friend invite. Inviter and invitee are added to each other’s friend list |
Block | Allows a player top block another player from sending them invites by adding them to a blocklist |
DeclineFriendInvite() | Declines a friend invite |
DisableIncomingFriendInvites() | Prevents a player from receiving friend invites |
EnableIncomingFriendInvites() | Allows player to receive friend invites |
ForceSync() | Forcibly synchronizes the player client FriendApi with the friend information in the Pragma Engine backend |
GetFriends() | Retrieves a list of Friend objects in a player’s friend list |
GetReceivedInvites() | Retrieves a list of Friend Overview objects representing players whose friend invites you have not yet accepted/rejected |
GetSentInvites() | Retrieves a list of Friend Overview objects representing players who have not responded yet to your friend invites |
GetBlockedList() | Retrieves a list of Friend Overview object representing players who are blocked from sending the player a friend invite |
Initialize() | Initializes the Friend API. Required to use the Friend SDK functions. |
RemoveFriend() | Removes a friend from your friend list using the friend’s social ID |
SendFriendInviteByDisplayName() | Sends an invite using the invitee’s display name |
SendFriendInviteBySocialId() | Sends an invite using the invitee’s social ID |
Unblock() | Removes a player from another player’s blocklist, allowing the unblocked player to send the unblocker friend invites |
Events #
There are several friend-related events that player clients can listen to. The following table describes the bindable events relevant to the Friend service.
The following events are handled by the player client.
Event | Trigger | Data returned |
---|---|---|
OnFriendsListChanged | A friend is added or removed from a player’s friend list, or a friend’s presence status changes | list of Friends on your friend list |
OnFriendUpdated | A friend’s presence status changes | Friend |
OnSentInvitesChanged | The status of a sent invite changes | list of FriendOverview for pending sent invites |
OnReceivedInvitesChanged | The status of a received invite changes | list of FriendOverviews for pending received invites |
OnBlockedListChanged | An account is added or removed from the player’s blocklist | list of FriendOverviews for accounts on your blocklist |
OnFriendInviteReceived | A player receives an invite | FriendOverview |
OnFriendInviteAccepted | An invitee accepts a friend invite | FriendOverview |
OnFriendInviteDeclined | An invitee declines a friend invite | FriendOverview |
OnRemovedAsFriend | A player is removed from another player’s friend list | Friend |
OnIncomingFriendInvitesEnabledChanged | A player’s ability to receive invites changes | true/false |
If notifications from the engine are received out of order due to a network issue, the friend cache will automatically refresh and the ‘On Changed’ events will be broadcasted.
Presence API #
The table below contains a list of the SDK methods relevant to the presence feature. These methods are available via the PresenceApi
.
Methods #
method | description |
---|---|
Initialize() | Initializes the Presence API. Required to use the Presence SDK functions. |
SetAsOnline() | Appears as “online” to friends in the game instance |
SetAsAway() | Appears as “away” to friends in the game instance |
SetRichPresence() | Sets rich presence |
SetPresence() | Sets basic presence and rich presence at the same time |
GetPresenceCache() | Retrieves presence status for current player |
ForceSync() | Forcibly synchronizes the player client PresenceApi with the presence information in the Pragma Engine backend |
Events #
The following events are related to the Presence feature.
To optimize server-load management, Pragma engine only sends Presence-related events to friends who are online.
Event | Trigger | Data returned |
---|---|---|
OnPresenceChanged | Your presence status changes | the updated Presence |