简体   繁体   English

Facebook Auth和Firebase - 如何在同一Facebook应用程序下添加4个应用程序?

[英]Facebook Auth and Firebase - How to add 4 apps under same Facebook app?

Let's say I have 4 apps, "Uber Clone" for iOS and Android and "Uber Driver Clone" for iOS and Android. 假设我有4个应用程序,iOS和Android的“Uber Clone”以及iOS和Android的“Uber Driver Clone”。 I am using the same Firebase project for all 4 since they share the same database. 我为所有4个使用相同的Firebase项目,因为它们共享相同的数据库。

When it comes to Facebook Auth though, I can only add a single Facebook app to Firebase. 说到Facebook Auth,我只能向Firebase添加一个Facebook应用程序。 And for every Facebook App I can only add a single iOS and a single Android app. 对于每个Facebook应用程序,我只能添加一个iOS和一个Android应用程序。 Therefore how can I make this work? 因此,我该如何使这项工作?

Firebasers, any recommendation/solution in mind? Firebasers,还有任何建议/解决方案吗?

A single Facebook App is allowed to connect to multiple iOS apps and multiple Android apps. 允许单个Facebook应用程序连接到多个iOS应用程序和多个Android应用程序。 For iOS apps, you can specify multiple Bundle ID at Facebook App settings page. 对于iOS应用程序,您可以在Facebook App设置页面指定多个Bundle ID

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. 假设您使用Firebase进行身份验证,我认为您使用实时数据库或Cloud Firestore来存储用户数据。 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. 这样您就不必创建多个Facebook应用程序。 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. 希望这可以帮助。

Multiple apps on a single Facebook app 单个Facebook应用上的多个应用

  1. Go to your Facebook developer console 转到您的Facebook开发者控制台
  2. Go to your app's page 转到您应用的页面
  3. Go to the basic settings 转到基本设置

在此输入图像描述

  1. Add all relevant bundle IDs 添加所有相关的捆绑包ID
  2. Here's the key: Add a different URL Scheme suffix for each app. 这是关键:为每个应用添加不同的URL Scheme后缀。 This differentiates each iOS app under your single Facebook App. 这可以区分您的单个Facebook应用程序下的每个iOS应用程序。

在此输入图像描述

  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!) 在每个应用中,info.plist添加后缀信息(确保更新URL方案并添加“FacebookURLSchemeSuffix”!)

在此输入图像描述

  1. Now each of your apps is under the same Facebook App, and thus can register under the same Firebase Realtime Database. 现在,您的每个应用程序都在同一个Facebook应用程序下,因此可以在同一个Firebase实时数据库下注册。 Check this out for more info: Two iOS apps using the same Facebook app ID - is it possible? 查看此信息以获取更多信息: 使用相同Facebook应用程序ID的两个iOS应用程序 - 是否可能?

At this point in time, it does not seem possible to have multiple FB apps under a single Firebase Realtime Database. 此时,似乎无法在单个Firebase实时数据库下拥有多个FB应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM