Playtolia Entitlements API allows you to manage player entitlements such as premium subscriptions, permanent unlocks, and time-limited access to content. Entitlements are automatically granted when players make purchases and can be checked to unlock features, grant access to premium content, or enable special abilities in your game.
Import the PlaytoliaSDK.Runtime to your script by adding the using directive
EntitlementsController.cs
Copy
using PlaytoliaSDK.Runtime;
Call the GetAllEntitlements function to retrieve all player entitlements
EntitlementsController.cs
Copy
// Get all player entitlementsvar entitlements = PlaytoliaEntitlements.GetAllEntitlements();
Make sure your player is authenticated before calling GetAllEntitlements or any other PlaytoliaEntitlements function. Entitlements API requires authentication and will return empty lists or null values until the player is successfully logged in.
Entitlements are automatically updated when players make purchases. If you need to refresh entitlements manually, use PlaytoliaEntitlements.Refresh() function.
You can retrieve specific entitlements using different identifiers
EntitlementsController.cs
Copy
// Get entitlement by grant ID (returns single entitlement)var entitlement = PlaytoliaEntitlements.GetEntitlementByGrantId("premium_pass");// Get multiple entitlements by grant ID (returns list)var entitlements = PlaytoliaEntitlements.GetEntitlementsByGrantId("premium_pass");// Get entitlement by store item IDvar entitlementByItem = PlaytoliaEntitlements.GetEntitlementByItemId("premium_subscription");
Here’s a practical example of how to check if a player has premium access:
PremiumManager.cs
Copy
using PlaytoliaSDK.Runtime;using UnityEngine;public class PremiumManager : MonoBehaviour{ void Start() { // Listen to entitlement changes PlaytoliaEntitlements.AddListener(CheckPremiumStatus); // Initial check CheckPremiumStatus(); } void CheckPremiumStatus() { var premiumEntitlement = PlaytoliaEntitlements.GetEntitlementByGrantId("premium_pass"); // When using GetEntitlementByGrantId, you don't need to check IsExpired property. // PlaytoliaEntitlements only return valid entitlements for queries around a specific item, grant, or ID. // If the player has no valid entitlements for that item, function will return null if (premiumEntitlement != null) { EnablePremiumFeatures(); } else { DisablePremiumFeatures(); } } void EnablePremiumFeatures() { Debug.Log("Premium features enabled!"); // Enable premium UI, unlock content, etc. } void DisablePremiumFeatures() { Debug.Log("Premium features disabled"); // Show premium upgrade prompts } void OnDestroy() { PlaytoliaEntitlements.RemoveListener(CheckPremiumStatus); }}
Purchases: New entitlements granted from successful purchases
Expiration: Time-limited entitlements expiring
Renewals: Subscription renewals
Manual refresh via PlaytoliaEntitlements.Refresh()
EntitlementTracker.cs
Copy
public void Start(){ PlaytoliaEntitlements.AddListener(() => { var entitlements = PlaytoliaEntitlements.GetAllEntitlements(); Debug.Log($"Player has {entitlements.Count} total entitlements"); var activeEntitlements = entitlements.Where(e => !e.IsExpired).ToList(); Debug.Log($"Active entitlements: {activeEntitlements.Count}"); });}