Nan Nan - 13 days ago 8
iOS Question

Facebook Login Status Check Issue

When user open Facebook Setting View, how to identify the current log in status. And if it is logged, how can i retrieve the users' further information. such as birthday, age, gender, etc.

i wrote this piece of code, which is not working. Thanks in advance.

- (void)viewDidLoad {
[super viewDidLoad];

if ([FBSDKAccessToken currentAccessToken]) {

//Going to another ViewController, which include user's name,
//age, photo and so on.
} else {
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];

loginButton.center = self.view.center;
[self.view addSubview:loginButton];
}


}

Answer
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
  if (!error) {
     NSLog(@”fetched user:%@”, result);
  }
 }];
}

Try this its working .

https://developers.facebook.com/docs/ios/change-log-4.x here is document to get information about SDK 4.0

Here are Some graph api key.

"public_profile", 
"email", 
"user_friends" , 
"user_hometown", 
"user_work_history" ,
"user_birthday" ,
"user_education_history