NullPointerException
NullPointerException

Reputation: 37681

Firebase analytics logs events without initializing it's instance with java code?

In the guide, you can see that these steps are necessary:

// Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);

But are those lines of code necessary? or will it log my activity opens without writting one line of code? (just the apply plugin on the gradle file)

I'm asking this because I'm not seeing anything in the dashboard when I'm testing it without writting that code (only the import, the json and the gradle lines) but my app can receive correctly push notifications.

Upvotes: 1

Views: 618

Answers (2)

adbitx
adbitx

Reputation: 2079

I think you are confused Push Notification with Analytics. There are automatic events that will report from your app by just linking Analytics SDK. For custom events, you will of course need those lines of code. The dashboard will show some automatically collected events like first_open, but if you don't have any custom events to log, it won't show any of them.

Upvotes: 0

Doug Stevenson
Doug Stevenson

Reputation: 317692

Firebase SDKs initialize automatically, and Analytics will send automatic events without having to write any code.

Upvotes: 1

Related Questions