Class FirebaseAnalyticsProvider

java.lang.Object
com.codename1.analytics.AbstractAnalyticsProvider
com.codename1.analytics.FirebaseAnalyticsProvider
All Implemented Interfaces:
AnalyticsProvider

public class FirebaseAnalyticsProvider extends AbstractAnalyticsProvider

A provider that forwards analytics to the native Firebase Analytics SDK. On Android and iOS, with Firebase configured in the build, events flow to the Firebase console. Where no native implementation is wired (the simulator, the desktop build, or a build without Firebase set up) the provider degrades silently to a no-op, so it is always safe to register:

Analytics.addProvider(new FirebaseAnalyticsProvider());

How the native call is wired

Unlike a NativeInterface (which exists for the build server to generate per-app native peers), this provider talks to the platform through a small FirebaseAnalyticsProvider.Bridge. The Codename One build supplies the concrete bridge for the target and registers it via registerBridge(Bridge) before the app starts:

  • Android: a bridge that calls FirebaseAnalytics.getInstance(context).logEvent(...) / setUserId / setUserProperty directly. Requires google-services.json and the Firebase Gradle plugin in the build.
  • iOS: a bridge whose methods are declared native and implemented in Objective-C (FIRAnalytics). Requires GoogleService-Info.plist and the Firebase pods.
  • Everything else (simulator, desktop): no bridge is registered, so the provider is a no-op.

Firebase is enabled with the codename1.arg.android.firebaseAnalytics / codename1.arg.ios.firebaseAnalytics build hints, which is what makes the build register the bridge.