Skip to content

Commit 53c06f8

Browse files
authored
Add support for firebase options (#18)
1 parent 0e74ee6 commit 53c06f8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Sources/SegmentFirebase/FirebaseDestination.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@ public class FirebaseDestination: DestinationPlugin {
4646
public let type = PluginType.destination
4747
public let key = "Firebase"
4848
public var analytics: Segment.Analytics? = nil
49-
50-
public init() { }
51-
49+
50+
private var firebaseOptions: FirebaseOptions? = nil
51+
52+
public init(firebaseOptions: FirebaseOptions? = nil) {
53+
self.firebaseOptions = firebaseOptions
54+
}
55+
5256
public func update(settings: Settings, type: UpdateType) {
5357
// we've already set up this singleton SDK, can't do it again, so skip.
5458
guard type == .initial else { return }
@@ -63,7 +67,11 @@ public class FirebaseDestination: DestinationPlugin {
6367
if (FirebaseApp.app() != nil) {
6468
analytics?.log(message: "Firebase already configured, skipping")
6569
} else {
66-
FirebaseApp.configure()
70+
if let options = firebaseOptions {
71+
FirebaseApp.configure(options: options)
72+
} else {
73+
FirebaseApp.configure()
74+
}
6775
}
6876
}
6977

0 commit comments

Comments
 (0)