Development Note/iOS
[objc] iOS 페이스북 로그인(Feat.PhotoUrl 얻기)
JamesChun
2021. 5. 11. 14:05
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://developers.facebook.com/docs/ios/graph?locale=ko_KR