Class FirebaseModule
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. UnderMOCALIB_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
nullon failure.
- GetRemoteBool(string, bool)
Returns a Remote Config bool value, or
defaultValueif not fetched from the server.
- GetRemoteDouble(string, double)
Returns a Remote Config double value, or
defaultValueif not fetched from the server.
- GetRemoteFloat(string, float)
Returns a Remote Config float value, or
defaultValueif not fetched from the server.
- GetRemoteInt(string, int)
Returns a Remote Config integer value, or
defaultValueif not fetched from the server.
- GetRemoteLong(string, long)
Returns a Remote Config long value, or
defaultValueif not fetched from the server.
- GetRemoteString(string, string)
Returns a Remote Config string value. Falls back to
defaultValueif 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_impressionevent to Firebase Analytics. UnderMOCALIB_USE_COST_CENTER, also logs a secondary event (ad_revenue_sdkfor standard formats orad_revenue_additionfor 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 aniap_sdkevent 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
onGrantedcallback 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
boolparameter istrueon success,falseon failure.