MocaLib API Reference

MocaLib is a Unity 6 modular SDK wrapper library by Titipi Games.

Each module wraps a third-party SDK behind a consistent, async-first interface. Modules are individually enabled via scripting define symbols (MOCALIB_USE_<MODULE>), so only the modules you need are compiled into your build.

Installation

Add MocaLib to your project via the Unity Package Manager. Open Packages/manifest.json and add the entry under "dependencies":

{
  "dependencies": {
    "com.titipi.mocalib": "git://github.com/TITIPI-GAMES/unity-mocalib-v2.git?path=Assets/Titipi/MocaLib#main",
    ...
  }
}

To pin to a specific release, replace #main with a tag or commit hash, e.g. #v2.1.0.

Enable modules

After importing, open Edit → Project Settings → Player → Other Settings → Scripting Define Symbols and add the defines for the modules you need (see the table below). Modules with always on in the Define column require no symbol.

Modules

Module Define Description
AdjustModule MOCALIB_USE_ADJUST_MODULE Attribution, events, ad revenue, purchase validation
AppLovinModule MOCALIB_USE_APPLOVIN_MODULE MAX mediation — App Open, Banner, Interstitial, Rewarded
AppsFlyerModule MOCALIB_USE_APPSFLYER_MODULE Attribution, events, ad revenue, purchase validation
ByteBrewModule MOCALIB_USE_BYTEBREW_MODULE Custom events, user properties, purchases
CommonModule (always on) iOS ATT request; call before any SDK init
FacebookModule MOCALIB_USE_FACEBOOK_MODULE Facebook SDK init and app activation
FirebaseInAppMessagingModule MOCALIB_USE_FIREBASEINAPMESSAGING_MODULE Native FIAM campaigns with local media caching
FirebaseModule MOCALIB_USE_FIREBASE_MODULE Analytics, Crashlytics, Remote Config, Push
GameAnalyticsModule MOCALIB_USE_GAMEANALYTICS_MODULE Design events, resource economy tracking
IAPModule MOCALIB_USE_IAP_MODULE Unity IAP v5 purchase flow (event-driven StoreController) with optional server validation
LeaderboardModule MOCALIB_USE_FIREBASE_LEADERBOARD_MODULE Firestore leaderboards with server-side rank calculation
NetworkModule (always on) On-demand connectivity check and background polling
PlayerProfileModule MOCALIB_USE_FIREBASE_LEADERBOARD_MODULE Firestore-backed player profile with anonymous auth
RatingModule MOCALIB_USE_RATING_MODULE Native in-app review / store rating prompt
ServerTimeModule MOCALIB_USE_SERVERTIME_MODULE Authoritative UTC time from Titipi server
UtilityModule (always on) Logging helpers, platform info, version, locale, IAP receipt parsing

Initialization Order

CommonModule.RequestATTracking();           // iOS ATT — must be first
await FirebaseModule.Initialize(config);
await AppLovinModule.Initialize(config);
await IAPModule.Initialize(config, products);
await AppsFlyerModule.Initialize(config);
await NetworkModule.Initialize();
NetworkModule.Enable(checkInterval: 15f, timeout: 5);
// ... other modules