10

Let's say I have 4 apps, "Uber Clone" for iOS and Android and "Uber Driver Clone" for iOS and Android. I am using the same Firebase project for all 4 since they share the same database.

When it comes to Facebook Auth though, I can only add a single Facebook app to Firebase. And for every Facebook App I can only add a single iOS and a single Android app. Therefore how can I make this work?

Firebasers, any recommendation/solution in mind?

rgoncalv
  • 5,825
  • 6
  • 34
  • 61
  • give your users roles? – Brendan Whiting Mar 18 '18 at 00:40
  • The problem is rather related to API communication. How do I make a single Facebook App connect to 4 apps (exchange keys, Bundle ID's, package names, etc)? – rgoncalv Mar 18 '18 at 00:48
  • A single Facebook App is only allowed to connect to a single iOS app and a single Android app (thus 2 apps so far). There *might* be a way to connect a single Firebase project to two Facebook apps though – rgoncalv Mar 18 '18 at 00:49

3 Answers3

5

Multiple apps on a single Facebook app

  1. Go to your Facebook developer console
  2. Go to your app's page
  3. Go to the basic settings

enter image description here

  1. Add all relevant bundle IDs
  2. Here's the key: Add a different URL Scheme suffix for each app. This differentiates each iOS app under your single Facebook App.

enter image description here

  1. In each of your apps info.plist add the suffix information (Make sure both the URL scheme is updated and the "FacebookURLSchemeSuffix" is added!)

enter image description here

  1. Now each of your apps is under the same Facebook App, and thus can register under the same Firebase Realtime Database. Check this out for more info: Two iOS apps using the same Facebook app ID - is it possible?

At this point in time, it does not seem possible to have multiple FB apps under a single Firebase Realtime Database.

Peter Tao
  • 1,668
  • 6
  • 18
  • 29
2

A single Facebook App is allowed to connect to multiple iOS apps and multiple Android apps. For iOS apps, you can specify multiple Bundle ID at Facebook App settings page.

mono
  • 4,340
  • 3
  • 21
  • 49
2

Taken you're using Firebase for authentication, I presume you're using either Real Time Database or Cloud Firestore to store user data as well. In your user data model, you can add user types.

For example,

user_type : "driver"

Then query users like so:

DBreference.collection("users").whereField("user_type", isEqualTo: "driver").getDocuments() {(querySnapshot, error) in 

if error != nil { print(error.debugDescription) 
return 
} 

else if let users = querySnapshot.documents {

for user in users {
guard let userType = user.data()["user_type"] as? String else { return } 
print(userType) 
} 

} 

}

This way you don't have to create multiple Facebook apps. Just use the one you have and segment users and their priviliges accordingly. For example, upon login on both apps, do a check, whether the is user trying to log in as a driver or a passenger.

if currentUser.userType != "passenger" {
print("You can't log into the passanger app with your driver's account.")
}

Hope this helps.

KLD
  • 162
  • 2
  • 10
  • Ah, only now I realised the true nature of your question. It's a longshot since I don't know about your situation and requirements, but you can also just create a single app per platform and again, using user roles, let them access either driver's or passenger's segments of the same app. – KLD Mar 23 '18 at 10:46