cancel
Showing results for 
Search instead for 
Did you mean: 

Entitlement Check issues

foxvalleysoccer
Protege

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?

oculusissue.JPG

public class OculusPlatformEntitlementCheck : MonoBehaviour
{

    [Tooltip("Show debug messages")]
    public bool debugMode = false;
    [Tooltip("Quit app on Entitlement Check Fail")]
    public bool quitOnFail = true;
    [Tooltip("Standalone mode allows you to initialize the Platform SDK in test and development environments")]
    private bool standaloneMode = false;

    private string appID = "";

    // init params for standalone mode
    struct OculusInitParams
    {
        public int sType;
        public string email;            // oculus developer account email
        public string password;         // oculus developer account password
        public System.UInt64 appId;
        public string uriPrefixOverride;
    };

    // run on awake
    void Awake()
    {
        //if(debugMode)
        //    Oculus.Platform.Core.LogMessages = true;

        // set the pc app id
        appID = Oculus.Platform.PlatformSettings.AppID;

        // if on mobile use the mobile app id
#if UNITY_ANDROID
        appID = Oculus.Platform.PlatformSettings.MobileAppID;
#endif

        // Keep this alive until finished checking
        DontDestroyOnLoad(this);

        // check for valid appID
        CheckAppID();

        // check if running in the first scene
        CheckScene();

        // Asynchronous method (recommended)
        if (!standaloneMode)
            Oculus.Platform.Core.AsyncInitialize();

        // Synchronous method
        // if(!standaloneMode)
        //      Oculus.Platform.Core.Initialize(appID);

        //if (standaloneMode)
        //Oculus.Platform.InitializeStandaloneOculus(OculusInitParams);

        // handle the callback message
        Oculus.Platform.Entitlements.IsUserEntitledToApplication().OnComplete(CheckCallback);
    }

    // check for valid appID
    private void CheckAppID()
    {
        bool badAppID = false;

        // handle bad app id
        if (appID == "")
        {
            Debug.LogError("Entitlement Check: Error! missing appID " + System.Environment.NewLine +
                " You can create a new application and obtain an App ID from the developer dashboard" + System.Environment.NewLine +
                " https://dashboard.oculus.com/");
            badAppID = true;
        }

        if (badAppID)
            Debug.LogWarning("Invalid App ID");
    }

    // check if running in the first scene
    private void CheckScene()
    {
        // check to make sure we're running in the first scene to improve chance of checking within 10 seconds
        int sceneID = SceneManager.GetActiveScene().buildIndex;
        if (sceneID == 0 && debugMode)
        {
            Debug.Log("Entitlement Check: Loaded in first scene");
        }
        else if (sceneID != 0 && debugMode)
        {
            Debug.LogWarning("Entitlement Check: Not loaded in first scene! " + sceneID);
        }
    }

    // handle the callback message
    private void CheckCallback(Oculus.Platform.Message msg)
    {
        if (!msg.IsError)
        {
            // Entitlement check passed
            if (debugMode)
                Debug.LogWarning("Entitlement Check: Passed");
        }
        else
        {
            // Entitlement check failed
            // NOTE: You may not allow the user to proceed in your app after a failed entitlement check.
            Debug.LogWarning("Entitlement Check: Failed!");
            Debug.Log("Entitlement Check: Core Initialized " + Oculus.Platform.Core.IsInitialized());

            // time since startup check
            if (Time.realtimeSinceStartup > 10)
                Debug.LogWarning("Entitlement Check: Timeout. Must check within 10 seconds.");

            // default to quiting the application on faild entitlement check
            if (quitOnFail)
            {
                UnityEngine.Application.Quit();

#if UNITY_EDITOR
                UnityEditor.EditorApplication.isPlaying = false;
#endif
            }
        }

        if (debugMode)
            Debug.Log("Entitlement Check: " + Time.realtimeSinceStartup + " seconds");

        FinishCheck();
    }

    // finish the check and cleanup
    private void FinishCheck()
    {
        if (debugMode)
            Debug.Log("Entitlement Check: Completed");
        Destroy(this);
    }


}

 

 

6 REPLIES 6

sSvvSs
Protege

Short answer: To use oculus API in play mode you need to switch to windows platform, build windows build, release beta branch to oculus and install it, see details at my answer here: https://forums.oculusvr.com/t5/Unity-Development/Cloud-Storage-V2-How-do-i-use-it-in-Unity/td-p/8652...

foxvalleysoccer
Protege

I'm trying to run it from my device not in the unity editor. I get the 3 dots with that script. 

what user name do i need to have logged in on the image I showed? Is it test users that i set up in my dashboard or my facebook/oculus account?

You can set there any valid user, both test user or your own. I think once I had issue with 3 dots... Can't remember for sure why... But there is a chance that unity build apk for vulkan API, try to remove it and leave only ogl

foxvalleysoccer
Protege

Hmmm thanks for the suggestion. I had vulkun already removed. 

volcansettings.JPG

sSvvSs
Protege

Seems fine for me... Maybe issue is in version? Like it's should be 0.1...

Here is rest of my settings:

sSvvSs_0-1622753148441.png

 

foxvalleysoccer
Protege

I got entitlement check working with this script!

public class AppEntitlementCheck : MonoBehaviour
{

    void Awake()
    {
        try
        {
            Core.AsyncInitialize();
            Entitlements.IsUserEntitledToApplication().OnComplete(EntitlementCallback);
        }
        catch (UnityException e)
        {
            Debug.LogError("Platform failed to initialize due to exception.");
            Debug.LogException(e);
            // Immediately quit the application.
            UnityEngine.Application.Quit();
        }
    }


    // Called when the Oculus Platform completes the async entitlement check request and a result is available.
    void EntitlementCallback(Message msg)
    {
        if (msg.IsError) // User failed entitlement check
        {
            // Implements a default behavior for an entitlement check failure -- log the failure and exit the app.
            Debug.LogError("You are NOT entitled to use this app.");
            UnityEngine.Application.Quit();
        }
        else // User passed entitlement check
        {
            // Log the succeeded entitlement check for debugging.
            Debug.Log("You are entitled to use this app.");
        }
 
    }

}