Table of Contents

Class FirebaseModule

Namespace
Titipi.MocaLib2

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

InitializeAsync(FirebaseModuleConfig)

Initializes the Firebase SDK and enables Analytics collection. When UseRemoteConfig is enabled, the Remote Config fetch and activate complete before this returns, so GetRemote* reads are reliable immediately after. Push notification setup (when enabled) is started in the background and not awaited. Under MOCALIB2_USE_FIREBASE_APP_CHECK, registers the platform App Check provider before SDK init.

Methods

GetAnalyticsInstanceIdAsync()

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 MOCALIB2_USE_COST_CENTER, also logs an ad_revenue_sdk event that includes value in micros, lifetime revenue, and gameplay context.

LogEvent(string)

Logs a named Firebase Analytics event with no parameters.

LogEvent(string, params Parameter[])

Logs a named Firebase Analytics event with one or more Parameter instances.

LogEvent(string, Dictionary<string, object>)

Logs a named Firebase Analytics event with mixed-type key-value parameters. long, int, double, and float values are forwarded as their native numeric types; all other values are converted to strings.

LogEvent(string, Dictionary<string, string>)

Logs a named Firebase Analytics event with string key-value parameters.

LogEvent(string, string, double)

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

LogEvent(string, string, long)

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

LogEvent(string, string, string)

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

LogPurchase(Product, string, int)

Under MOCALIB2_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.

RefreshRemoteConfigAsync()

Re-fetches and activates Remote Config at runtime (e.g. after the app resumes from background), then returns whether it succeeded. Also raises OnRemoteConfigFetched. Read the updated values with the GetRemote* methods afterwards. The initial fetch already runs during InitializeAsync(FirebaseModuleConfig); use this only to pull fresh values without restarting.

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 InitializeAsync(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.