Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Tr1NgleBoss's avatar
Tr1NgleBoss
Honored Guest
4 years ago

Problems with getting Oculus ID from Oculus.Platform.Users.GetLoggedInUser()

Hi. Im making game rn, and trying to add own database-based cloud storage. So i need to get Oculus ID of each player to send it to database. And its working perfectly in Unity Editor, but when im trying to do same thing in Quest - its just returning null, and there is no errors.

Can someone help me? And i actually think that this problem is because of Platform.Core.Initialize(id), but idrk.

1 Reply

  • There is my code btw:

        public static string OculusUserID = "";
        private void Start()
        {
            Oculus.Platform.Core.Initialize();
            Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
        }
        void EntitlementCallback(Message msg)
        {
            if (msg.IsError) // User failed entitlement check
            {
                
                Debug.LogError("You are NOT entitled to use this app.");
                UnityEngine.Application.Quit();
            }
            else 
            {
                Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetOculusUserIDCallback);
                Debug.Log("You are entitled to use this app.");
            }
        }
        private void GetOculusUserIDCallback(Message<Oculus.Platform.Models.User> callback)
        {
            if (callback.IsError)
            {
                OculusUserID = "Error:" + callback.GetError().Message;
            }
            else
            {
                OculusUserID = callback.Data.OculusID;
            }
        }