Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reporting to two Firebase Projects Simultaneously

Is there a way a single iOS app build can report to two Firebase projects at the same time? I want to send events to my own personal Firebase account and my client's Firebase account simultaneously, from the same build.

I've investigated using Google Tag Manager to solve this, but with no success.

like image 359
Nicholas Angel Avatar asked Aug 07 '17 10:08

Nicholas Angel


1 Answers

It should be possible.

Have a look at this post from the Firebase blog. The same principle applies to all platforms but the iOS specific stuff is at the bottom.

By the looks of it, this is an example of the briefest (iOS) code you'd need:

// Alt: load from plist using |FIROptions(contentsOfFile:)|
let options =  FIROptions(googleAppID: googleAppID, bundleID: bundleID, GCMSenderID: GCMSenderID, APIKey: nil, clientID: nil, trackingID: nil, androidClientID: nil, databaseURL: databaseURL, storageBucket: nil, deepLinkURLScheme: nil)

FIRApp.configure(withName: "secondary", options: fileopts)
guard let secondary = FIRApp.init(named: "secondary")
      else { assert(false, "Could not retrieve secondary app") }

let secondaryDatabase = FIRDatabase.database(app: secondary);
like image 106
edant92 Avatar answered Oct 12 '22 21:10

edant92