我正在将我的应用程序与Facebook和Google Firebase连接起来 . 我按照所有步骤操作,并且每件事情都运行正常,但Firebase Google中生成的数据库是空的 . 我是否需要使用实时数据库,然后以编程方式存储FB用户数据?或者当您登录时,FB用户信息会自动存储在Firebase数据库中 . 供参考:https://firebase.google.com/docs/auth/ios/facebook-login
-(void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error
{
if (error == nil) {
FIRAuthCredential *credential = [FIRFacebookAuthProvider
credentialWithAccessToken:[FBSDKAccessToken currentAccessToken]
.tokenString];
[[FIRAuth auth] signInWithCredential:credential
completion:^(FIRUser *user, NSError *error) {
// ...
}];
} else {
NSLog(@"%@", error.localizedDescription);
}
}
- (IBAction)FBLogin:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login
logInWithReadPermissions: @[@"public_profile", @"email", @"user_friends",@"user_birthday",@"user_location"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error) {
NSLog(@"Process error");
} else if (result.isCancelled) {
NSLog(@"Cancelled");
} else {
NSLog(@"Logged in");
[self performSegueWithIdentifier:@"GotoMainMenu" sender:self];
}
}];
}
1 回答
...对不起,我刚刚编辑了这个,因为我意识到你没有使用JavaScript . 我会留下答案,因为它可能仍然有用 .
等到基于密码的身份验证 . 这就是真正有趣的开始! :-)
有关Facebook的事情是他们默认情况下不会向用户发送电子邮件 . 我相信您可以通过他们的开发人员门户请求访问它 . 其他提供商提供电子邮件 .
在存储displayName,photoURL和/或电子邮件方面,您要将它们存储在Auth系统中,该系统将记住数据服务器端,...用于密码帐户 . oAuth帐户在登录时提取此数据,因此不会过时 .
我有一个工作的Web auth样板文件,它将为您提供一个开端 . 它在https://github.com/rhroyston/firebase-auth .
以下是如何在一次通过中执行基于密码的用户 .