Incoming Friend Notifications
Last updated on
When a player sends a friend request to another player, the receiver will get an incoming friend request notification. You'll need to set up a delegate to enable this notification. Use the following function to implement the delegate for incoming friend request notifications.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnIncomingRequestFriendsNotifDelegate(AccelByte::Api::Lobby::FRequestFriendsNotif::CreateLambda([](const FAccelByteModelsRequestFriendsNotif& Result)
{
// Do something if OnIncomingRequestFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnIncomingFriendRequest += result =>
{
if (result.IsError)
{
// Do something if OnIncomingFriendRequest has an error
Debug.Log($"Error OnIncomingFriendRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnIncomingFriendRequest has been successful
}
};
Accepted Friend Request Notification
Use the following function to set up a notification for when your friend accepts your friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnFriendRequestAcceptedNotifDelegate(AccelByte::Api::Lobby::FAcceptFriendsNotif::CreateLambda([](const FAccelByteModelsAcceptFriendsNotif& Result)
{
// Do something if OnFriendRequestAcceptedNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestAccepted += result =>
{
if (result.IsError)
{
// Do something if FriendRequestAccepted has an error
Debug.Log($"Error FriendRequestAccepted, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestAccepted has been successful
}
};
Rejected Friend Request Notification
Use the following function to set up a notification for when a player rejects your friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnRejectFriendsNotifDelegate(AccelByte::Api::Lobby::FRejectFriendsNotif::CreateLambda([](const FAccelByteModelsRejectFriendsNotif& Result)
{
// Do something if OnRejectFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestRejected += result =>
{
if (result.IsError)
{
// Do something if FriendRequestRejected has an error
Debug.Log($"Error FriendRequestRejected, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestRejected has been successful
}
};
Canceled Outgoing Friend Request Notification
Use the following function to set up a notification when another player cancels their friend request.
- Unreal Engine
- Unity
FRegistry::Lobby.Connect();
FRegistry::Lobby.SetOnCancelFriendsNotifDelegate(AccelByte::Api::Lobby::FCancelFriendsNotif::CreateLambda([](const FAccelByteModelsCancelFriendsNotif& Result)
{
// Do something if OnCancelFriendsNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().FriendRequestCanceled += result =>
{
if (result.IsError)
{
// Do something if FriendRequestCanceled has an error
Debug.Log($"Error FriendRequestCanceled, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if FriendRequestCanceled has been successful
}
};
Unfriend Notification
Use this function to set up a notification when a player unfriends another player.
- Unreal Engine
- Unity
FRegistry::Lobby.SetOnUnfriendNotifDelegate(AccelByte::Api::Lobby::FUnfriendNotif::CreateLambda([](const FAccelByteModelsUnfriendNotif& Result)
{
// Do something if OnUnfriendNotifDelegate has been successful
}));
AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnUnfriend += result =>
{
if (result.IsError)
{
// Do something if OnUnfriend has an error
Debug.Log($"Error OnUnfriend, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnUnfriend has been successful
}
};