Develop

Group Presence Overview

In order for the Meta Horizon platform to understand where users are in your app and whether they are in a joinable state, the platform uses the Group Presence system. A user must have Group Presence enabled and IsJoinable set to True for features like App Invites to work. Make sure your app is an immersive app, as the current platform cannot support Group Presence for non-immersive apps like 2D panel apps or regular Android apps.

Quickstart

The following is an example of the function used to implement Group Presence in your app.
#include "OVRPlatformCppRequests.h"
#include "OVRPlatformOptions.h"

void AMyActor::SetPresence()
{
    FOvrGroupPresenceOptions GroupPresenceOptions;
    GroupPresenceOptions.DestinationApiName = TEXT("MyTestDestination");
    GroupPresenceOptions.MatchSessionId = TEXT("test123");
    GroupPresenceOptions.LobbySessionId = TEXT("test456");
    GroupPresenceOptions.IsJoinable = true;

    OvrPlatform_GroupPresence_Set(
        GetGameInstance(),
        GroupPresenceOptions,
        OvrPlatform_GroupPresence_Set_Delegate::CreateLambda(
            [](bool bIsError, FString ErrorMsg)
            {
                if (bIsError)
                {
                    UE_LOG(LogTemp, Error, TEXT("Error in setting presence: %s"), *ErrorMsg);
                }
                else
                {
                    UE_LOG(LogTemp, Log, TEXT("Group presence successfully set!"));
                }
            }));
}
For an example of group presence’s implementation in an app, check the Unreal-SharedSpaces sample app.

Concept explanations

The following breakdown shows new concepts, and their functions within the Platform SDK.

DestinationApiName

GroupPresenceOptions.DestinationApiName = TEXT("MyTestDestination");
The destination name (in this case “MyTestDestination”) refers to a destination that has already been created in the Meta Horizon Developer Dashboard. If you try running this code without a destination, it won’t work as there’s no destination to point to. If you haven’t created a destination, or if this is your first time creating a destination, check the Destinations Overview.

LobbySessionId and MatchSessionId

GroupPresenceOptions.MatchSessionId = TEXT("test123");
GroupPresenceOptions.LobbySessionId = TEXT("test456");
MatchSessionId and LobbySessionId are both used to determine if users are playing together. These lines become more important as you continue to build out your app. If two users share the same Match and Lobby session IDs, they should be in the same multiplayer instance together. This is useful for the Invite to App feature when User A sends an invite to User B to join them at a “MultiplayerLobby” destination. When User B launches your app, these lines allow you to know which MultiplayerLobby to place User B into.
As your app grows in popularity, you could have hundreds, or thousands of MultiplayerLobby instances running at the same time and MatchSessionId and LobbySessionId determines exactly which instance of a destination User A is in, so that they can be successfully joined by User B in that same instance.

IsJoinable

GroupPresenceOptions.IsJoinable = true;
Typically there would be additional logic to determine whether or not a user is joinable, but because this is a quickstart guide, it is currently hardcoded to true.
With the OvrPlatform_GroupPresence_Set() function set up, you can now call it after the Platform SDK has been initialized.