Facebook登录状态检查问题 [英] Facebook Login Status Check Issue
本文介绍了Facebook登录状态检查问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当用户打开Facebook设置视图时,如何识别当前的登录状态。如果记录,我如何检索用户的进一步信息。如生日,年龄,性别等。
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];
}
}
推荐答案
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密钥
"public_profile",
"email",
"user_friends" ,
"user_hometown",
"user_work_history" ,
"user_birthday" ,
"user_education_history
这篇关于Facebook登录状态检查问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文