gpt4 book ai didi

ios - Facebook 登录用户数据未显示在 firebase 控制台中

转载 作者:搜寻专家 更新时间:2023-11-01 06:19:50 26 4
gpt4 key购买 nike

我已经使用 firebase 在我的应用程序中实现了电子邮件和 Facebook 登录。我的代码如下:

对于 fb 登录:

FireBaseHelper.fireBaseHelper.BASE_REF.authWithOAuthProvider("facebook", token: "123") { (error, data) -> Void in

APP_DELEGATE.hideActivityIndicator()
if error != nil {
print(error)
self.loginErrorAlert("Oops!", message: "Check your username and password.")
} else {

// Be sure the correct uid is stored.

NSUserDefaults.standardUserDefaults().setValue(data.uid, forKey: "uid")

// Enter the app!

self.performSegueWithIdentifier("CurrentlyLoggedIn", sender: nil)
}
}

对于电子邮件注册:

     let username = usernameField.text
let email = emailField.text
let password = passwordField.text

if username != "" && email != "" && password != "" {

APP_DELEGATE.showActivityIndicator()

FireBaseHelper.fireBaseHelper.BASE_REF.createUser(email, password: password, withValueCompletionBlock: { error, result in



if error != nil {
APP_DELEGATE.hideActivityIndicator()
// There was a problem.
self.signupErrorAlert("Oops!", message: "Having some trouble creating your account. Try again.")

} else {

// Create and Login the New User with authUser
FireBaseHelper.fireBaseHelper.BASE_REF.authUser(email, password: password, withCompletionBlock: {
err, authData in

let user = ["provider": authData.provider!, "email": email!, "username": username!]

FireBaseHelper.fireBaseHelper.USER_REF.childByAppendingPath(authData.uid).setValue(user, withCompletionBlock: { (error, firebase) -> Void in

if error != nil {
APP_DELEGATE.hideActivityIndicator()
self.signupErrorAlert("Oops!", message: "Having some trouble creating your account. Try again.")

}else
{
APP_DELEGATE.hideActivityIndicator()
// Store the uid for future access - handy!
NSUserDefaults.standardUserDefaults().setValue(result ["uid"], forKey: "uid")

// Enter the app.
self.performSegueWithIdentifier("NewUserLoggedIn", sender: nil)

}
})
})
}
})

}else
{
signupErrorAlert("Oops!", message: "Don't forget to enter your email, password, and a username.")
}

和辅助类代码:

class FireBaseHelper: NSObject {

static let fireBaseHelper = FireBaseHelper()

private var _BASE_REF = Firebase(url: "https://poc-demoApp.firebaseio.com")
private var _USER_REF = Firebase(url: "https://poc-demoApp.firebaseio.com/users")
var BASE_REF: Firebase {
return _BASE_REF
}

var USER_REF: Firebase {
return _USER_REF
}

var CURRENT_USER_REF: Firebase {
let userID = NSUserDefaults.standardUserDefaults().valueForKey("uid") as! String

let currentUser = Firebase(url: "\(BASE_REF)").childByAppendingPath("users").childByAppendingPath(userID)

return currentUser!
}
}

问题是当我用电子邮件用户注册时,我可以在 firebase 的仪表板上看到该用户数据,而当我用 fb 注册时,该用户的数据没有显示在仪表板上,请告诉我问题所在。我有什么想念的吗?显示fb注册成功

最佳答案

Firebase 仅存储电子邮件+密码用户列表。它不会存储与社交提供商(如 Facebook)签约的应用用户的任何数据。因此,这些用户的 Firebase 控制面板上没有任何可显示的内容。

如果您想在数据库中存储有关 Facebook 用户的信息,请参阅 storing user data 部分.

关于ios - Facebook 登录用户数据未显示在 firebase 控制台中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36005620/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com