0

I want to implement e-commerce apps on IOS and Android. I can divide the apps into two parts less secured, more secured. I can say more secure is a case of accepting payments in the app.So for this purpose, I want to have separate login systems for entering into the app and making payments.I am using Firebase Authentication and in that Password Authentication.So at the start of the project if we want to use Firebase(for Authentication, Database)we need to add google-services.json for Android App and GoogleService-Info.plist for IOS App. But now I want to add two firebase projects for a single app. How is it possible?

Divya Galla
  • 513
  • 1
  • 9
  • 31
  • Check this lanswer:- https://stackoverflow.com/questions/39632243/multiple-firebase-projects-in-one-app – Ravi Hirani Mar 24 '18 at 04:25
  • Have a look at the Firebase documentation: https://firebase.google.com/docs/configure/#support_multiple_environments_in_your_ios_application – Frank van Puffelen Mar 24 '18 at 04:26
  • 1
    @FrankvanPuffelen I don't have two src folders like the example.I only have one and I want to use two different firestore projects in the same app.This is the use case user wants to buy a product, up to that point the app needs to use 1 Database when the user wants to pay then the user is redirected to payments methods from then onwards app uses another database(for security reasons) – Divya Galla Mar 24 '18 at 05:20

2 Answers2

1

Use multiple firebase projects in single application

Simply can access multiple projects through FirebaseApp configure.

Configuration

        let secondaryOptions = FirebaseOptions(googleAppID: "your google app id",
                                               gcmSenderID: "your gcm id")
        secondaryOptions.apiKey = "your api key"
        secondaryOptions.projectID = "your projectid"
        
        secondaryOptions.bundleID = "your bundle id"
        secondaryOptions.databaseURL = "https://yourproject.firebaseio.com"
        secondaryOptions.storageBucket = "yourproject.appspot.com"
        secondaryOptions.androidClientID = "yourproject.apps.googleusercontent.com"
        secondaryOptions.deepLinkURLScheme = "myapp://"
        secondaryOptions.storageBucket = "yourprojectId.appspot.com"
        secondaryOptions.appGroupID = nil
        FirebaseApp.configure(name: "secondary", options: secondaryOptions)

Usage

        guard let secondary = FirebaseApp.app(name: "secondary")
         else { assert(false, "Could not retrieve secondary app") }
         
        let secondaryDb = Database.database(app: secondary)
Elavarasan K
  • 116
  • 3
-3

in your firebase. open up a project and click on 'add another project'.

and then select app for IOS or Android. You are done.

  • 1
    Thanks for taking the time to contribute an answer. It’s because of helpful peers like yourself that we’re able to learn together as a community. Here are a few tips on how to make your answer great: [How do I write a good answer](https://stackoverflow.com/help/how-to-answer). – Brien Foss Mar 24 '18 at 04:44
  • Hi, @user9238383 I am not asking about how to use single Firebase Project by multiple apps.Its exact opposite to the question I have asked. – Divya Galla Mar 24 '18 at 04:46