Rudedog
Rudedog

Reputation: 4692

Using Firebase Analytics with a named FirebaseApp

I'm trying to integrate Firebase Analytics with my application. I've linked the proper frameworks and installed the plist that Google provides.

The following code works fine and I can see my_event showing up in the Firebase Debug View:

FirebaseApp.configure()
Analytics.logEvent("my_event")

This code does not work:

let plist = Bundle.main.url(
  forResource: "GoogleService-Info", 
  withExtension: "plist"
)!
let options = FirebaseOptions(contentsOfFile: plist.path)!
FirebaseApp.configure(name: "customName", options)
Analytics.logEvent("my_event")

In the console I see the message

2020-03-26 15:27:08.969113-0700 dmpremier[83834:51654982] 6.21.0 - <AppMeasurement>[I-ACS025018] Event not logged. Call +[FIRApp configure]: my_event

So I am assuming that Analytics only works if you configure a default Firebase app. Is this correct, or is there something else I can do to link analytics to a named app?

Upvotes: 0

Views: 586

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317828

Analytics only works with the default Firebase app. This is also true for Cloud Messaging, and perhaps other products that are deeply tied to analytics.

You can tell by looking at the APIs - if they don't accept a FirebaseApp instance to work with, then they only work with the default.

Upvotes: 1

Related Questions