Developer Documentation · Integration Package
Zero-Friction Integration
Download a ready-to-use package from the dashboard — binaries, scripts, and a pre-filled config are bundled together. Extract the ZIP at your Unity project root (so its Assets/ merges into yours) and press Play. No key copy-paste. No manual configuration.
One Download
Full ZIP containing SDK binaries, C# scripts, and gamemantra_config.json — pre-filled with your API key and game ID.
Keys Pre-Filled
api_key and game_id are injected at download time. You never copy, paste, or type them into your project.
Auto-Bootstrap
GameMantraAutoInit.cs fires via [RuntimeInitializeOnLoadMethod]. The SDK initialises before your first scene loads.
Choose Your Environment
The environment is baked into gamemantra_config.json at download time — the SDK uses the correct API endpoint automatically. No code change is needed when moving from sandbox to production: just re-download the package.
https://sandbox.gamemantra.aiTLS not verifiedDownload the Package
Go to Dashboard → Games, open your game's detail drawer, select the environment above, then click Download Package. The ZIP contains everything — no separate binary download needed.
gamemantra_unity_YourGame_sandbox.zip
What's inside gamemantra_config.json
This file is generated fresh for your game at every download. You never edit it — just use it. Showing config for 🧪 sandbox environment.
{
"api_key": "gm_test_sk_YOUR_SANDBOX_KEY",
"game_id": "33333333-3333-4333-8333-333333333333",
"environment": "sandbox",
"base_url": "https://sandbox.gamemantra.ai",
"auto_login": true,
"player_id_source": "device",
"flutter_data_folder": "flutter_data",
"flutter_engine_so": "libflutter_engine.so",
"pixel_ratio": 1,
"bootstrap_version": "1.0.0",
"debug_logging": true
}api_keyInjected at download time — never copy-pasted
game_idYour game UUID from the wizard — injected automatically
environment"sandbox" — drives TLS verification and key format
base_urlhttps://sandbox.gamemantra.ai
pixel_ratioAlways 1.0 — never auto-detect from device DPI (§14)
debug_loggingtrue in sandbox — verbose logcat output
Auto-Bootstrap Code
The bootstrap script is included in the package and runs automatically — no scene setup, no MonoBehaviour drag-and-drop required.
using UnityEngine;
using Gamemantra;
// GameMantraAutoInit.cs — included in every download package.
// [RuntimeInitializeOnLoadMethod] fires automatically when the game starts.
// No manual scene setup, no drag-and-drop, no key copy-paste.
public static class GameMantraAutoInit
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
private static void Bootstrap()
{
// 1. Load gamemantra_config.json from Resources/ (pre-filled at download time)
var config = GameMantraConfig.Load(); // → Resources/gamemantra_config.json
// 2. Initialise SDK (api_key + game_id already in config, never typed manually)
var result = GameMantraSDK.Init(config);
if (result != GMResult.OK)
{
Debug.LogError($"[GameMantra] Init failed: {result}");
return;
}
// 3. Register player (device ID used when player_id_source = "device")
GameMantraSDK.LoginPlayer(SystemInfo.deviceUniqueIdentifier);
Debug.Log("[GameMantra] SDK ready — offer pipeline active.");
}
}Verify on Device
Run the game on an Android device and check logcat for this boot sequence. The correct base_url confirms the selected environment was picked up correctly.
HTTP Status Reference
http=200Success — SDK initialised, kill switch = NONEhttp=0Transport error — no network OR libcurl stub activehttp=401Invalid API key — check which key type matches the environmenthttp=403game_id in URL doesn't match the API key's registered game_idPlayer Identification
The SDK supports four player_id_source values in gamemantra_config.json — pick the one that matches your auth model. The canonical field-by-field reference (matching the comments in GameMantraConfig.cs) lives on Player identity.
Unity: uses SystemInfo.deviceUniqueIdentifier — zero-friction, no user accounts. Experience overlay: optional loginPlayer() with no args generates an in-process UUID v4. Default player_id_source: "device" in your downloaded config.
⚠️ Device ID resets on wipe / reinstall. For a fourth option, see advertising_id (ATT on iOS).
Pass your auth system's user ID after the player logs in. Set "player_id_source": "custom" and "auto_login": false in the config, then call the helper from your auth callback.
// Unity — call from your auth system's success callback
// Firebase Auth:
FirebaseAuth.DefaultInstance.StateChanged += (s, e) => {
var user = e.auth.CurrentUser;
if (user != null)
GameMantraSDKHelper.SetGameUserId(user.UserId);
};
// Google Play Games Services:
PlayGamesPlatform.Instance.Authenticate(success => {
if (success)
GameMantraSDKHelper.SetGameUserId(
PlayGamesPlatform.Instance.GetUserId());
});
// Steam:
if (SteamManager.Initialized)
GameMantraSDKHelper.SetGameUserId(
SteamUser.GetSteamID().ToString());
// Any custom auth system:
GameMantraSDKHelper.SetGameUserId(myAuth.CurrentUser.Id);SDK decodes your auth JWT (Base64URL, no signature verification — the server verifies signatures). Extracts the named claim as the player identifier. Set "player_id_source": "jwt".
// Unity — pass the raw JWT from your backend
// Firebase ID token → extracts "user_id" claim:
string token = await firebaseUser.GetIdTokenAsync();
GameMantraSDKHelper.SetPlayerFromJwt(token, "user_id");
// Generic JWT → extracts "sub" by default:
GameMantraSDKHelper.SetPlayerFromJwt(token);
// Custom backend JWT with a different claim:
GameMantraSDKHelper.SetPlayerFromJwt(token, "player_id");Common JWT claim names by platform:
"user_id" or "sub""sub""sub""PlayFabId" (custom)"sub"any claim you defineConfig for each strategy
// Strategy 1 — Auto (default, no changes needed)
{
"player_id_source": "device",
"auto_login": true
}
// Strategy 2 — Game user ID (set in config, call SetGameUserId() in code)
{
"player_id_source": "custom",
"auto_login": false
}
// Strategy 3 — JWT claim (set in config, call SetPlayerFromJwt() in code)
{
"player_id_source": "jwt",
"jwt_player_id_claim": "sub",
"auto_login": false
}AI Integration Prompt
Copy this prompt into any AI coding assistant (Cursor, Copilot, Claude, ChatGPT) to get a step-by-step integration guide tailored to your specific auth system.
I'm integrating the GameMantra AI monetization SDK into my Unity game. My game setup: - Engine: Unity (C#) - Auth system: [Firebase / Google Play Games / Steam / Custom backend / No auth] - Player ID available: [e.g. Firebase user.uid / Steam SteamID / none — use device ID] - Target platform: Android I have already: 1. Downloaded the GameMantra integration package from the dashboard 2. Placed the .so files in the correct folders 3. Added gamemantra_config.json to Resources/ Now I need help with: 1. Connecting my auth system's player ID to GameMantra's LoginPlayer call 2. The exact code to call after my auth callback fires (show me a complete example) 3. How to verify on device that the player session was registered (logcat lines to look for) 4. When to call getNextOffer() to trigger the first AI offer (based on game events) Please provide copy-paste ready code for my auth system.
Fill in the bracketed fields with your specific setup before sending to the AI assistant.
Critical Rules
- Never set
pixel_ratiofrom device DPI — always 1.0. - Never call
runApp()beforeinitFlutterUnreal(). - Never commit a production package (with
gm_live_sk_*) to a public repository. - Re-download when switching sandbox → production — do not hand-edit
gamemantra_config.json.