当用户打开 Facebook 设置 View 时,如何识别当前登录状态。如果已记录,我如何检索用户的更多信息。例如生日、年龄、性别等。
我写了这段代码,但没有用。提前致谢。
- (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];
}
}
最佳答案
if ([FBSDKAccessToken currentAccessToken]) {
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSLog(@”fetched user:%@”, result);
}
}];
}
试试这个它的工作。
https://developers.facebook.com/docs/ios/change-log-4.x 这里是获取SDK 4.0信息的文档
这里有一些图形 API key 。
"public_profile",
"email",
"user_friends" ,
"user_hometown",
"user_work_history" ,
"user_birthday" ,
"user_education_history
关于ios - Facebook 登录状态检查问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40815955/