Steam friend list has not presence state in build game

Hello,

In the editor in standalone mode, I only see my friends who are not offline and I can see their status.
(It’s OK)

But when on my game build, I see all my friends and no status…
(All state return true)
Why?

I use Advanced sessions.

1 Like

I am noticing this same issue, using 5.4.2 source build. Have you figured this out? Happens for me both with advanced sessions and a custom implementation so I don’t think it is an issue with Advanced Sessions

1 Like

This is happening to me as well, using launcher version 5.4.2. Has anyone found a workaround?

From Unreal 5.4 changelog I noticed this:

  • Fixed an issue with the Friends interface in the Steam OSS not properly polling and retaining presence data.
1 Like

I inspected the GetPresence() method in the engine’s OnlineFriendsInterfaceSteam.cpp and made a workaround for this issue (using AdvancedSessions plugin).

In AdvancedFriendsLibrary.h, add this to the UAdvancedFriendsLibrary class:

static const FOnlineUserPresence GetPresence(const FUniqueNetId& Id);

In AdvancedFriendsLibrary.cpp:

const FOnlineUserPresence EmptyPresence;

const FOnlineUserPresence UAdvancedFriendsLibrary::GetPresence(const FUniqueNetId& Id)
{
  // TODO: insert return statement here
  if (IOnlineSubsystem* SteamOSS = IOnlineSubsystem::Get(STEAM_SUBSYSTEM))
  {
    // Get the steam presence interface
    if (auto OnlinePresence = SteamOSS->GetPresenceInterface().Get())
    {
      TSharedPtr<FOnlineUserPresence> Presence;
      EOnlineCachedResult::Type Result = OnlinePresence->GetCachedPresence(Id, Presence);

      if(Presence.IsValid())
      {
        auto P = *Presence.Get();
        return P;
      }
    }
  }

  return EmptyPresence;
}

Then modify the GetStoredFriendsList method’s for loop with this:

    for (int32 i = 0; i < FriendList.Num(); i++)
    {
      FBPFriendInfo BPF;
      const FOnlineUserPresence pres = GetPresence(FriendList[i]->GetUserId().Get());

      BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
      BPF.DisplayName = FriendList[i]->GetDisplayName();
      BPF.RealName = FriendList[i]->GetRealName();
      BPF.UniqueNetId.SetUniqueNetId(FriendList[i]->GetUserId());
      BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;

      BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
      BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
      BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
      BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
      // #TODO: Check back in on this in shipping, epic is missing the UTF8_TO_TCHAR call on converting this and its making an invalid string
      //BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
      BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
      BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;

      FriendsList.Add(BPF);
    }

Now in blueprints I’m getting the friend list array like this:

1 Like

This saved me a lot of headache. Thank you for posting this.

Unfortunately this fix did not work for me, the code still works fine in standalone PIE but when packaged the friends list does not populate at all. No idea why this is happening