Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Oculus Entitlement Check

Discussion in 'VR' started by JD_FVTC, Jun 2, 2021.

  1. JD_FVTC

    JD_FVTC

    Joined:
    Oct 20, 2017
    Posts:
    54
    How do I test entitlement? I have this script on my opening screen.
    When I build and run on the device all I get is 3 dots. Remove the script my game loads.

    In my oculus settings I am logged in with my facebook id same id as I used to create account on my quest and same as oculus dashboard. Should this be a test user account instead of my FB?

    Code (CSharp):
    1. public class OculusPlatformEntitlementCheck : MonoBehaviour
    2. {
    3.  
    4.     [Tooltip("Show debug messages")]
    5.     public bool debugMode = false;
    6.     [Tooltip("Quit app on Entitlement Check Fail")]
    7.     public bool quitOnFail = true;
    8.     [Tooltip("Standalone mode allows you to initialize the Platform SDK in test and development environments")]
    9.     private bool standaloneMode = false;
    10.  
    11.     private string appID = "";
    12.  
    13.     // init params for standalone mode
    14.     struct OculusInitParams
    15.     {
    16.         public int sType;
    17.         public string email;            // oculus developer account email
    18.         public string password;         // oculus developer account password
    19.         public System.UInt64 appId;
    20.         public string uriPrefixOverride;
    21.     };
    22.  
    23.     // run on awake
    24.     void Awake()
    25.     {
    26.         //if(debugMode)
    27.         //    Oculus.Platform.Core.LogMessages = true;
    28.  
    29.         // set the pc app id
    30.         appID = Oculus.Platform.PlatformSettings.AppID;
    31.  
    32.         // if on mobile use the mobile app id
    33. #if UNITY_ANDROID
    34.         appID = Oculus.Platform.PlatformSettings.MobileAppID;
    35. #endif
    36.  
    37.         // Keep this alive until finished checking
    38.         DontDestroyOnLoad(this);
    39.  
    40.         // check for valid appID
    41.         CheckAppID();
    42.  
    43.         // check if running in the first scene
    44.         CheckScene();
    45.  
    46.         // Asynchronous method (recommended)
    47.         if (!standaloneMode)
    48.             Oculus.Platform.Core.AsyncInitialize();
    49.  
    50.         // Synchronous method
    51.         // if(!standaloneMode)
    52.         //      Oculus.Platform.Core.Initialize(appID);
    53.  
    54.         //if (standaloneMode)
    55.         //Oculus.Platform.InitializeStandaloneOculus(OculusInitParams);
    56.  
    57.         // handle the callback message
    58.         Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(CheckCallback);
    59.     }
    60.  
    61.     // check for valid appID
    62.     private void CheckAppID()
    63.     {
    64.         bool badAppID = false;
    65.  
    66.         // handle bad app id
    67.         if (appID == "")
    68.         {
    69.             Debug.LogError("Entitlement Check: Error! missing appID " + System.Environment.NewLine +
    70.                 " You can create a new application and obtain an App ID from the developer dashboard" + System.Environment.NewLine +
    71.                 " https://dashboard.oculus.com/");
    72.             badAppID = true;
    73.         }
    74.  
    75.         if (badAppID)
    76.             Debug.LogWarning("Invalid App ID");
    77.     }
    78.  
    79.     // check if running in the first scene
    80.     private void CheckScene()
    81.     {
    82.         // check to make sure we're running in the first scene to improve chance of checking within 10 seconds
    83.         int sceneID = SceneManager.GetActiveScene().buildIndex;
    84.         if (sceneID == 0 && debugMode)
    85.         {
    86.             Debug.Log("Entitlement Check: Loaded in first scene");
    87.         }
    88.         else if (sceneID != 0 && debugMode)
    89.         {
    90.             Debug.LogWarning("Entitlement Check: Not loaded in first scene! " + sceneID);
    91.         }
    92.     }
    93.  
    94.     // handle the callback message
    95.     private void CheckCallback(Oculus.Platform.Message msg)
    96.     {
    97.         if (!msg.IsError)
    98.         {
    99.             // Entitlement check passed
    100.             if (debugMode)
    101.                 Debug.LogWarning("Entitlement Check: Passed");
    102.         }
    103.         else
    104.         {
    105.             // Entitlement check failed
    106.             // NOTE: You may not allow the user to proceed in your app after a failed entitlement check.
    107.             Debug.LogWarning("Entitlement Check: Failed!");
    108.             Debug.Log("Entitlement Check: Core Initialized " + Oculus.Platform.Core.IsInitialized());
    109.  
    110.             // time since startup check
    111.             if (Time.realtimeSinceStartup > 10)
    112.                 Debug.LogWarning("Entitlement Check: Timeout. Must check within 10 seconds.");
    113.  
    114.             // default to quiting the application on faild entitlement check
    115.             if (quitOnFail)
    116.             {
    117.                 UnityEngine.Application.Quit();
    118.  
    119. #if UNITY_EDITOR
    120.                 UnityEditor.EditorApplication.isPlaying = false;
    121. #endif
    122.             }
    123.         }
    124.  
    125.         if (debugMode)
    126.             Debug.Log("Entitlement Check: " + Time.realtimeSinceStartup + " seconds");
    127.  
    128.         FinishCheck();
    129.     }
    130.  
    131.     // finish the check and cleanup
    132.     private void FinishCheck()
    133.     {
    134.         if (debugMode)
    135.             Debug.Log("Entitlement Check: Completed");
    136.         Destroy(this);
    137.     }
    138.  
    139.  
    140. }
     
  2. asdflzh

    asdflzh

    Joined:
    Jan 14, 2020
    Posts:
    2
    Have you solved the problem?
     
  3. joeysipos

    joeysipos

    Joined:
    Jul 28, 2015
    Posts:
    41
    Any luck with this problem? Running into the same problem.