Getting facebook public profile of a person in ios app

后端 未结 2 861
迷失自我
迷失自我 2021-01-06 21:22

I am working on an ios app which requires Facebook Login.I have successfully implemented the login process.But now I am not able to find that how and where can i get the use

2条回答
  •  被撕碎了的回忆
    2021-01-06 21:39

    Below is the code for getting person public_profile using latest Facebook SDK v4.0.1. You need to use FBSDKProfile to get person profile.

    -(void)viewDidLoad{
            FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
            [self.view addSubview:loginButton];
    
            self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
            self.loginButton.delegate = self;
            [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(profileUpdated:) name:FBSDKProfileDidChangeNotification object:nil];
    
             }
    
        -(void)profileUpdated:(NSNotification *) notification{
             NSLog(@"User name: %@",[FBSDKProfile currentProfile].name);
             NSLog(@"User ID: %@",[FBSDKProfile currentProfile].userID);
        }
    
        - (void)  loginButton:(FBSDKLoginButton *)loginButton
        didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
                        error:(NSError *)error{
    
        }
    
        - (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton{
    
        }
    

提交回复
热议问题