New to facebook sdk, and can't find a suitable answer to this. I am using facebook sdk to only log in to my iOS application. On login, I want to get the username and email address of the logged in person. How can I get those details without using FacebookGraph API

有帮助吗?

解决方案

check this ...

     - (void)sessionStateChanged:(FBSession *)session
                  state:(FBSessionState) state
                  error:(NSError *)error    {

switch (state) {
    case FBSessionStateOpen:
        if (!error) {
            // We have a valid session
            NSLog(@" Info : Valid FBSession found...");
            [self fetchFacebookUserInfo];
        }
        break;
    case FBSessionStateClosed:
    case FBSessionStateClosedLoginFailed: {
          NSLog(@" Info : No Valid FBSession found***");
    }
        break;
    default:
        break;
}
}


 - (void)fetchFacebookUserInfo {
       if ([self sessionIsOpen]) {
    [FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                                           id<FBGraphUser> user,
                                                           NSError *error) {
        if (!error) {
             NSLog(@"Username %@",user.name);
             NSLog(@"Email %@",[user objectForKey:@"email"]);
            }
  }
  }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top