We require to get the Display name and Username for unique identification of our devices as they are logged in with specific Oculus account. I have setup an account on Oculus developer dashboard as required as well as doing all the certifications and requirements > data use checkup.
The code in the Game Manager class is as follows:
public bool InitOculus()
{
try
{
Core.Initialize(123****132);
Users.GetLoggedInUser().OnComplete(LoggedInUser);
}
catch (UnityException e)
{
Debug.LogException(e);
UnityEngine.Application.Quit();
}
return true;
}
void LoggedInUser(Message msg)
{
string name = "";
string username = "";
if (msg.IsError)
{
Debug.LogError("Failed to retrieve Oculus user.");
}
else
{
User user = msg.GetUser();
ulong userId = user.ID;
Debug.Log("USER ID IS " + userId);
username = user.OculusID;
Users.Get(userId).OnComplete(message =>
{
if (!message.IsError)
{
name = message.Data.DisplayName;
}
else
{
var e = message.GetError();
Debug.LogError($"Error loading display name: {e.Message}.");
}
});
}
Debug.Log("Display Name " + name + " and the username is " + username);
}
I am posting here because there are some other posts (stackoverflow/Oculus) regarding this issue but they are either too old to be valid or unanswered. I have also tried the check entitlement and callback approach but that does not work either as our app is not published through Oculus store, we have in-house platform.
Thank you in advance.