简体   繁体   English

FBLoginView与Parse“登录Facebook”

[英]FBLoginView with Parse to “Login with Facebook”

I am using FBLoginView for my app to handle logging in with Facebook but I am also using Parse.com. 我正在使用FBLoginView为我的应用程序处理登录Facebook,但我也使用Parse.com。 I am struggling to figure out how I can create a new user in Parse if I don't login using Parse's PFFacebookUtils class. 如果我不使用Parse的PFFacebookUtils类登录,我正在努力弄清楚如何在Parse中创建新用户。 Does anyone know a good way to use FBLoginView with parse to achieve "Login with Facebook"? 有没有人知道使用FBLoginView和解析来实现“使用Facebook登录”的好方法?

Parse actually takes all the legwork out of this process by providing Facebook integration and a login view automatically for you. Parse实际上通过为您自动提供Facebook集成和登录视图来完成此过程中的所有工作。 You can use Parse's built-in Facebook login system like so: 您可以使用Parse的内置Facebook登录系统,如下所示:

[PFFacebookUtils logInWithPermissions:permissions block:^(PFUser *user, NSError *error) {
    if (!user) {
        NSLog(@"Uh oh. The user cancelled the Facebook login.");
    } else if (user.isNew) {
        NSLog(@"User signed up and logged in through Facebook!");
    } else {
        NSLog(@"User logged in through Facebook!");
    }
}];

When do you do this, 4 things will happen: 你什么时候这样做,会发生4件事:

  1. The user is shown the Facebook login dialog. 向用户显示Facebook登录对话框。
  2. The user authenticates via Facebook, and your app receives a callback using handleOpenURL. 用户通过Facebook进行身份验证,您的应用程序使用handleOpenURL接收回调。
  3. Parse SDK receives the Facebook data and saves it to a PFUser. Parse SDK接收Facebook数据并将其保存到PFUser。 If it's a new user based on the Facebook ID, then that user is created. 如果它是基于Facebook ID的新用户,则创建该用户。
  4. Your code block is called with the user. 您的代码块将与用户一起调用。

You can find a solid step-by-step in the documentation here: https://parse.com/docs/ios_guide#fbusers/iOS 您可以在此处的文档中找到一个可靠的步骤: https//parse.com/docs/ios_guide#fbusers/iOS

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

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