This question was created in reference to: [EOS - Presence [Content removed]
Hi there. We are trying to set Rich Presence for a game, however, there seems to be some confusion around what to do when using OnlineSubsystemEOS. We are not using OnlineServicesEOS, however.
On the Epic Dev Portal, we’ve set up our Localized Presence templates which are simple strings. When we call IOnlinePresence::SetPresence() we pass in the key which we defined in GameplayTags in the project, however when checking the overlay, the presence seems to just be set to the raw key string, and not the expected presence template.
Please find sample code from our ActivitiesSubsystem class attached. Calling SetPresence has worked for all other platforms, apart from EOS.
The EOS SDK seems to suggest we need to completely bypass OnlineSubsystem and make the SDK calls directly, but it seems like UserManagerEOS::SetPresence is performing all the necessary calls to the EOS SDK already…
Any clarity on this would be greatly appreciated
TL;DR: We are trying to set a presence string that we have set up on the Dev Portal in the templates, however, passing the template key in results in the raw key string being set.
void UActivitiesSubsystem::SetRichPresence(const FGameplayTag& ActivityId)
{
const IOnlineSubsystem* Oss = nullptr;
switch (UUserPlatformHelper::GetPlatform())
{
case EPlatform::Steam:
Oss = IOnlineSubsystem::Get(STEAM_SUBSYSTEM);
break;
case EPlatform::Epic:
Oss = IOnlineSubsystem::Get(EOS_SUBSYSTEM);
break;
// Other platforms omitted from code sample....
default:
UE_LOG(LogTemp, Error, TEXT("Cannot set rich presence. Unknown platform."));
return;
}
FOnlineUserPresenceStatus Status;
Status.State = EOnlinePresenceState::Online;
Status.StatusStr = GetActivityNameFromGameplayTag(ActivityId);
if (!Oss) return;
const IOnlinePresencePtr Presence = Oss->GetPresenceInterface();
const TSharedPtr<const FUniqueNetId> UserId = Oss->GetIdentityInterface()->GetUniquePlayerId(0);
if (!UserId.IsValid())
{
return;
}
Status.StatusStr = GetActivityNameFromGameplayTag(ActivityId);
// as a test and for example for this EPS post, we have added EOS-compatible presence properties here
Status.Properties.Add(DefaultPresenceKey, FVariantData(Status.StatusStr));
FString PresenceKey = GetActivityNameFromGameplayTag(ActivityId);
Status.Properties.Add(TEXT("presence_key"), FVariantData(PresenceKey));
Status.Properties.Add(DefaultPlatformKey, FVariantData(TEXT("WIN")));
Status.Properties.Add(DefaultAppIdKey, FVariantData(TEXT("GameTitleName")));
UE_LOG(LogActivities, Error, TEXT("Setting rich presence: %s"),
*Status.StatusStr);
Presence->SetPresence(*UserId, Status, FOnMyPresenceSetResult::CreateUObject(this, &UActivitiesSubsystem::OnSetPresenceComplete));
}
Regards,
Daniel Mendelowitz