Table of Contents

Class FirebaseModule

Namespace
Titipi.MocaLib

Wraps the Firebase Unity SDK, providing Analytics, Crashlytics, Remote Config, and Cloud Messaging. Not supported on WebGL — all methods return early with a warning when compiled for that platform.

public static class FirebaseModule
Inheritance
FirebaseModule
Inherited Members

Properties

Config

The config used to initialize this module.

IsInitialized

Whether the Firebase SDK has been initialized successfully.

Initialization

Initialize(FirebaseModuleConfig)

Initializes the Firebase SDK and enables Analytics collection. Optionally kicks off Remote Config fetch and push notification setup based on config. Under MOCALIB_USE_FIREBASE_APP_CHECK, registers the platform App Check provider before SDK init.

Methods

GetAnalyticsInstanceId()

Returns the Firebase Analytics instance ID asynchronously. Useful for linking Firebase events to other attribution systems (e.g., AppsFlyer). Times out after 5 seconds and returns null on failure.

GetRemoteBool(string, bool)

Returns a Remote Config bool value, or defaultValue if not fetched from the server.

GetRemoteDouble(string, double)

Returns a Remote Config double value, or defaultValue if not fetched from the server.

GetRemoteFloat(string, float)

Returns a Remote Config float value, or defaultValue if not fetched from the server.

GetRemoteInt(string, int)

Returns a Remote Config integer value, or defaultValue if not fetched from the server.

GetRemoteLong(string, long)

Returns a Remote Config long value, or defaultValue if not fetched from the server.

GetRemoteString(string, string)

Returns a Remote Config string value. Falls back to defaultValue if the key has not been fetched from the server (i.e., source is StaticValue) or is empty.

LogAdRevenue(AdImpressionData, string, Dictionary<string, string>, string, int, string)

Logs an ad_impression event to Firebase Analytics. Under MOCALIB_USE_COST_CENTER, also logs a secondary event (ad_revenue_sdk for standard formats or ad_revenue_addition for APPOPEN) that includes value in micros, lifetime revenue, and gameplay context.

LogEvent(string)

Logs a named Firebase Analytics event with no parameters.

LogEvent(string, Dictionary<string, object>)

Logs a named Firebase Analytics event with arbitrary typed parameters.

LogEvent(string, string, string)

Logs a named Firebase Analytics event with a single string parameter.

LogPurchase(Product, string, int)

Under MOCALIB_USE_COST_CENTER, logs an iap_sdk event with price, currency, product ID, and gameplay context. Firebase auto-tracks the standard purchase event via Unity IAP; this method adds the COST_CENTER-specific extended fields only.

RegisterForPushNotifications(Action, Action)

Starts listening for FCM push tokens and incoming messages. On iOS, also enables token registration on SDK init. Can be called at any time after Initialize(FirebaseModuleConfig) to request permission. The onGranted callback fires once when the FCM token is received.

SetUserProperty(string, string)

Sets a Firebase Analytics user property for audience segmentation.

Events

OnRemoteConfigFetched

Fired after Remote Config has been fetched and activated. The bool parameter is true on success, false on failure.