Friend Service Tasks #
Common objectives you can achieve using the Friend Service include:
- Initialize the Friend service (Required)
- Send a friend invite
- Accept or decline a friend invite
- Remove a friend from your friend list
- Invite a friend to join your party (obtain the friend’s Player ID, and then send a party invite using that value)
- View friend list and invite data
Pragma currently supports the Friend API in the Unreal SDK. Unity implementation is available through FriendServiceRaw.cs
.
Initialize the Friend service (Required) #
Before you can issue any Friend service calls using the Friend API, you must initialize the service using the Friend API Initialize
method. After you receive a successful response, you can begin using the Friend service API.
Player->FriendApi().Initialize(
FOnCompleteDelegate
);
The Initialize
method triggers the OnChanged
events, providing you with a list of friends and invites.
Related events:
Related errors:
Send a friend invite #
A player can send an invite to another player using the player’s social ID or display name. Social IDs and display names may be visible in game instances, on leaderboards, or communicated through methods outside of Pragma, such as via social media. Developers can access the SocialId
and DisplayName
via the Unreal UPragmaPartyPlayer
object. Pragma recommends sending invites by socialId if possible because display names can easily change. However, display names may be preferable if manually typing in a value.
When called, SendFriendInviteByDisplayName
and SendFriendInviteBySocialId
add a pending sent invite to the inviter’s friend list, and a pending received invite to the invitee’s friend list.
Invites do not expire.
Send a friend invite by social ID #
To send a friend invite using the invitee’s social ID, use the Friend API’s SendFriendInviteBySocialId
method.
Player->FriendApi().SendFriendInviteBySocialId(
SocialId,
FOnCompleteDelegate
);
SendFriendInviteBySocialIdV1(SendFriendInviteBySocialIdV1Request request,
Protocol.OnComplete<SendFriendInviteBySocialIdV1Response> callback)
Send a friend invite by display name #
To send a friend invite using the invitee’s display name, use the Friend API’s SendFriendInviteByDisplayName
method.
Player->FriendApi().SendFriendInviteByDisplayName(
DisplayName,
FOnCompleteDelegate
);
SendFriendInviteV1(SendFriendInviteV1Request request,
Protocol.OnComplete<SendFriendInviteV1Response> callback)
Related events:
Accept a friend request #
To accept a friend invite, use the Friend API’s AcceptFriendInvite
method with the inviter’s social ID. When accepted, the inviter and invitee are added to each other’s friend list.
Player->FriendApi().AcceptFriendInvite(
InviterSocialId,
FOnCompleteDelegate
);
RespondToFriendInviteV1(RespondToFriendInviteV1Request request,
Protocol.OnComplete<RespondToFriendInviteV1Response> callback)
To view pending friend invites, use GetReceivedInvites
.
Related events:
Decline a friend request #
To decline a friend invite, use the Friend API’s DeclineFriendInvite
with the inviter’s social ID.
Player->FriendApi().DeclineFriendInvite(
InviterSocialId,
FOnCompleteDelegate
);
RespondToFriendInviteV1(RespondToFriendInviteV1Request request,
Protocol.OnComplete<RespondToFriendInviteV1Response> callback)
To view pending friend invites, use GetReceivedInvites
.
Related events:
View friend list and invite data #
You can access friend list and invite data in the following ways:
Listen to events that communicate friend and invite information:
OnFriendListChanged
OnSentInvitesChanged
OnReceivedInvitesChanged
Use the following
Get
methods:- Unreal:
GetFriends
GetSentInvites
GetReceivedInvites
- Unity:
GetFriendListV1
See: Friend SDK methods and Friend events for more details.
- Unreal:
Remove a friend #
To remove a player from your friend list, use the Friend API’s RemoveFriend
with the player’s social ID. This call removes each player from the other player’s friend list.
Player->FriendApi().RemoveFriend(
SocialId
FOnCompleteDelegate
);
RemoveFriendV1(RemoveFriendV1Request request,
Protocol.OnComplete<RemoveFriendV1Response> callback)
Related events: