Steam friend list has not presence state in build game

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:

2 Likes