Skip to content

Commit

Permalink
Add support for firebase options (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiosdev authored Oct 5, 2023
1 parent 0e74ee6 commit 53c06f8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Sources/SegmentFirebase/FirebaseDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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()
}
}
}

Expand Down

0 comments on commit 53c06f8

Please sign in to comment.