티스토리 뷰

Firebase sdk 사용하지 않고 iOS에서 페이스북 로그인 구현하기

튜토리얼:

@import FBSDKCoreKit;
@import FBSDKLoginKit;

- (void)facebookAuth:(UIViewController*)uiview
{    
    FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
    [loginManager logInWithPermissions:@[ @"public_profile", @"email" ]
                    fromViewController:uiview
                               handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
    {
        if (error) {
            NSLog(@"%@", error.localizedDescription);
        } else if (result.isCancelled){
            NSLog(@"FBLogin cancelled");
        }else{
            if ([FBSDKAccessToken currentAccessToken])
            {
                [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me"
                                                   parameters:@{@"fields": @"id, name, picture.type(normal), email"}]
                 startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
                 {
                    if (!error) {
                        NSLog(@"%@", result);
                    }
                }];
            }
        }
    }];
}

스택오버플로우
https://stackoverflow.com/questions/29323244/facebook-ios-sdk-4-0how-to-get-user-email-address-from-fbsdkprofile

페이스북
https://developers.facebook.com/docs/ios/graph?locale=ko_KR

댓글