I want to implement Firebase google analytics in my custom keyboard for button click event.
Anyone please tell me how I can do this in swift.
Add firebase sdk and GoogleService-Info.plist file to keyboard extension target. Import firebase and configure it. FIRApp.configure() must be called only once per session:
import Firebase
class FirebaseConfigurator: NSObject {
static var onceToken: dispatch_once_t = 0
static func configure() {
dispatch_once(&onceToken) {
FIRApp.configure()
}
}
and
FirebaseConfigurator.configure()
FIRAnalytics.logEventWithName("button click event", parameters: nil).
FIRApp.configure() method calling again and throwing **error- [reason: 'Default app has already been configured.'] ** and app crash.
FIRApp.configure()twice where ever you're calling? It may fix the issue. Here is something similar : stackoverflow.com/questions/37910766/…