[Beginner] EOS Receiving Empty Friend List

Hey folks,

When trying to call the friends list I’m receiving an empty array with no friends. The desired result is EOS pulls friends from EGS and Steam.

Is there something I’m missing?

void GameInstance::GetAllFriends()
{

	UE_LOG(LogTemp, Warning, TEXT("Running GetAllFriends Function"));
	if (IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::GetByPlatform())
	{
		UE_LOG(LogTemp, Warning, TEXT("Checking if Online Subsystem is initialized"));
		if (IOnlineFriendsPtr FriendsPtr = OnlineSubsystem->GetFriendsInterface())
		{
			UE_LOG(LogTemp, Warning, TEXT("Checking if friends interface is initialized"));
			FriendsPtr->ReadFriendsList(
				0,
				TEXT(""),
				FOnReadFriendsListComplete::CreateUObject(this, &GameInstance::OnGetAllFriendsComplete)
				);
		}
	}

}

void GameInstance::OnGetAllFriendsComplete(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorStr)
{
	UE_LOG(LogTemp, Warning, TEXT("Checking if operation was successful"));


	if (bWasSuccessful)
	{
		UE_LOG(LogTemp, Warning, TEXT("Checking OnlineSubsystem in OnGetAllFriendsComplete"));
		if(IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::GetByPlatform())
		{
			UE_LOG(LogTemp, Warning, TEXT("Checking FriendsPtr in OnGetAllFriendsComplete"));
			if (IOnlineFriendsPtr FriendsPtr = OnlineSubsystem->GetFriendsInterface())
			{
				TArray<TSharedRef<FOnlineFriend>> FriendsList;
				if(FriendsPtr->GetFriendsList(0, TEXT(""), FriendsList))
				{
					UE_LOG(LogTemp, Warning, TEXT("Reading Friend list"));
					if(FriendsList.IsEmpty())
					{
						UE_LOG(LogTemp, Warning, TEXT("FriendsList Array is empty"));
					}

					for(TSharedRef<FOnlineFriend> Friend: FriendsList)
					{
						FString FriendName = Friend.Get().GetDisplayName();
						UE_LOG(LogTemp, Warning, TEXT("Friend: %s"), *FriendName);
					}
				}
				else
				{
					UE_LOG(LogTemp, Warning, TEXT("Failed GetFriendList. Error: %s"), *ErrorStr);
				}
			}
			else
			{
				UE_LOG(LogTemp, Warning, TEXT("FriendsPtr not valid in OnGetAllFriendsComplete. Error: %s"), *ErrorStr);
			}
		}

	}
	else
	{
		UE_LOG(LogTemp, Warning, TEXT("Error: %s"), *ErrorStr);
	}

}

1 Like

Having the same issue, did you, by chance find a solution?