Forum Discussion

DevBrain's avatar
DevBrain
Start Mentor
4 months ago

Building a Social VR Game From Scratch Part 1: Entitlement

So, I am building Baby VR, a social VR game that  I will build with the community on YouTube

While planning the curriculum,  I realized that before working on the core things like Networking, Voice Chat or Game Mechanics, we need to first integrate Baby VR into the Meta Horizon Store. And it starts with the Entitlement.

So, in this blog post, I will show you how I did the Entitlement for the Meta Horizon Store. Let's get started.

Introduction

If you're building a VR app for Meta Quest, you absolutely need to implement entitlement checking. There's no way around it. Without it, anyone could potentially access your app without actually purchasing it from the Meta Quest Store. Think of entitlement as your app's bouncer - it checks if someone actually paid to get in before letting them through the door.

 

Meta requires entitlement checks for apps published on their store, and it's really not optional if you want to protect your work and ensure users have legitimately obtained your application. According to Meta's official documentation.

In this blog post, I'll walk you through a real-world implementation that handles all the edge cases - retry logic, error handling, and proper user data retrieval. Let's dive in.

 

 How It Works: The Complete Flow

Before we get into the code, here's the big picture of how the entitlement process flows:

The system consists of a few key components working together=>

  1. MetaStoreManager - The main orchestrator that kicks everything off
  2. EntitlementHandler - Does the heavy lifting of verification
  3. Event System - Notifies other parts of your game when entitlement completes
  4. MetaPlayerData - Stores the user info we retrieve

 

Step-by-Step Implementation

 1. The MetaStoreManager: Your Entry Point

The `MetaStoreManager` is a Unity `MonoBehaviour` that orchestrates everything. It's simple - it initializes the entitlement handler and listens for when the entitlement completes:

When you call `Initialize()`, it kicks off the entitlement process. Once complete, it stores the player data for use throughout your game.

 

2. The EntitlementHandler: The Core Logic

This is where the real work happens. The handler performs a four-step verification process with automatic retry logic (up to 3 attempts with 2-second delays between retries):

The `CheckEntitlement()` method runs four critical steps in sequence - if any step fails, the whole process fails and retries:

Step 2 is the critical one- `CheckUserEntitlement()` calls `Entitlements.IsUserEntitledToApplication()` which queries Meta's servers to verify the user actually purchased your app. This is where the piracy protection happens.

The other steps retrieve user data (ID, display name, Oculus ID) and generate a cryptographic proof (nonce) that you can use for server-side verification later.

 

3. The Data Structure

After successful entitlement, you get a `MetaPlayerData` object containing:

public class MetaPlayerData

{

    public string UserId;        // Unique user identifier

    public string UserName;      // Display name

    public string AliasName;     // Oculus ID

    public string OculusNonce;   // Cryptographic proof for server verification

}

The`OculusNonce` is particularly important - it's a proof token you can send to your backend server to verify the user's identity securely.

 

Best Practices

When to check: Run entitlement as early as possible - ideally during your splash screen or initial loading. Don't let users access premium features until verification completes.

Error handling: The implementation includes automatic retry logic (3 attempts with 2-second delays), but you should also show user-friendly error messages and provide a manual retry option if all attempts fail.

Security: Never trust client-side verification alone. Always use the `OculusNonce` to verify user identity on your backend server for critical features. This prevents tampering and ensures real security.

Performance: The async/await pattern keeps everything non-blocking, so your game stays responsive during the verification process.

 

Common Issues and Solutions

Entitlement always fails? Make sure your app is properly configured in the Meta Developer Dashboard, and test on a device that has actually purchased the app. Network issues can also cause failures.

Platform not initializing? Verify the Oculus Platform SDK is properly imported and check your AndroidManifest.xml for required permissions. Also ensure you're testing on actual Quest hardware.

User data not retrieved? The user needs to be logged into their Oculus account, and privacy settings might be blocking access. Check both the device settings and ensure you're using a compatible SDK version.

 

Quick Integration Example

Here's the basic pattern for using this in your game:

 

Conclusion

Meta Store entitlement isn't optional - it's a requirement for protecting your VR application. The implementation we've covered gives you:

- ✅ Robust verification with automatic retry logic

- ✅ Complete user data retrieval for personalization  

- ✅ Event-based architecture that keeps your code clean

- ✅ Production-ready error handling

 

Remember to test on actual Quest hardware, verify your app configuration in the Meta Developer Dashboard, and always implement server-side verification using the `OculusNonce` for critical features.

This system provides a solid foundation that protects your app while keeping the user experience smooth. The retry logic handles network hiccups, and the event system keeps everything decoupled and maintainable. Let me know if you need the source code. 

 

Additional Resources

Meta's Official Entitlement Check Documentation

*This blog post is based on a production implementation. Always refer to the latest Meta documentation for the most up-to-date information and best practices.*

No RepliesBe the first to reply

→ Find helpful resources to begin your development journey in Getting Started

→ Get the latest information about HorizonOS development in News & Announcements.

→ Access Start program mentor videos and share knowledge, tutorials, and videos in Community Resources.

→ Get support or provide help in Questions & Discussions.

→ Show off your work in What I’m Building to get feedback and find playtesters.

→ Looking for documentation?  Developer Docs

→ Looking for account support?  Support Center

→ Looking for the previous forum?  Forum Archive

→ Looking to join the Start program? Apply here.

 

Recent Discussions