嗨,你可以给你一个视图控制器。对于使用 Facebook 登录,您可以参考本教程。将登录与 facebook 集成
重要步骤
第 1 步:在开发者应用上创建 Facebook 应用并配置您的 info.plist 文件
第 2 步:登录操作代码
- (IBAction)signInWithFacebookClicked:(id)sender {
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"email",@"user_friends"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
// The session is open. Get the user information and update the UI.
[FBRequestConnection startWithGraphPath:@"me"
parameters:@{@"fields": @"first_name,last_name, email"}
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Set the use full name.
NSLog(@"FBresponse: =>%@",result);
}
else{
NSLog(@"%@", [error localizedDescription]);
}
}];
}];
}
第三步:处理回调
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Handle the user leaving the app while the Facebook login dialog is being shown
// For example: when the user presses the iOS "home" button while the login dialog is active
[FBAppCall handleDidBecomeActive];
}
第 4 步:然后根据您的要求处理 FBSession 块。希望这会有所帮助。