From 53c06f8754e8d40067a9fd94566aea4a4d184fef Mon Sep 17 00:00:00 2001 From: Mateusz Fraczek Date: Thu, 5 Oct 2023 22:43:27 +0200 Subject: [PATCH] Add support for firebase options (#18) --- .../SegmentFirebase/FirebaseDestination.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/SegmentFirebase/FirebaseDestination.swift b/Sources/SegmentFirebase/FirebaseDestination.swift index f6c50b1..eab5763 100644 --- a/Sources/SegmentFirebase/FirebaseDestination.swift +++ b/Sources/SegmentFirebase/FirebaseDestination.swift @@ -46,9 +46,13 @@ public class FirebaseDestination: DestinationPlugin { public let type = PluginType.destination public let key = "Firebase" public var analytics: Segment.Analytics? = nil - - public init() { } - + + private var firebaseOptions: FirebaseOptions? = nil + + public init(firebaseOptions: FirebaseOptions? = nil) { + self.firebaseOptions = firebaseOptions + } + public func update(settings: Settings, type: UpdateType) { // we've already set up this singleton SDK, can't do it again, so skip. guard type == .initial else { return } @@ -63,7 +67,11 @@ public class FirebaseDestination: DestinationPlugin { if (FirebaseApp.app() != nil) { analytics?.log(message: "Firebase already configured, skipping") } else { - FirebaseApp.configure() + if let options = firebaseOptions { + FirebaseApp.configure(options: options) + } else { + FirebaseApp.configure() + } } }