简体   繁体   中英

Firebase Analytics - Can not logging only custom events

We're trying to use firebase analytics in our ios app.

Default events seems to be logged with no problem.

5.1.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: screen_view (_vs)

However, only custom event is not logged with this log below.

5.1.0 - [Firebase/Analytics][I-ACS025018] Event not logged. Call +[FIRApp configure]: custom_event_name

I think configurating is following the document. We have two different project's plist for each targets to setting up development environment to use different Firebase projects based on build type or target.

guard let path = Bundle.main.path(forResource: googleServiceInfoPlist, ofType: "plist"),
  let opts = FirebaseOptions(contentsOfFile: path) else {
  fatalError("Couldn't load config file")
}
FirebaseApp.configure(options: opts)

I guessed multiple plists causes this problem at first, but there was no changes with a GoogleService-Info.plist and calling FirebaseApp.configure() .

Sending event's func is just like this.

private func sendToFirebase(_ event: Trackable) {
 Analytics.logEvent(event.name, parameters: event.properties)
}

What are the possible causes?

Thank you.

I solved by myself.

This is caused by setting up cocoapods for embedded framework.

My Podfile was like below,

platform :ios, '11.0'
swift_version = '4.1'
use_frameworks!

target 'AppCore' do
  pod 'Firebase/Core'

  target 'App' do
    inherit! :search_paths
  end
end

AppCore is embedded framework.

pod 'Firebase/xxx' should be targeted to main app, not embedded framework.

I did:

  • Eliminate dependency of Firebase from embedded framework
  • Fixed podfile not targeting to embedded framework

then tracked customs events correctly.

我通过手动添加Firebase Analytics SDK解决了此问题https://firebase.google.com/docs/ios/setup#frameworks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM