我已经在我的应用程序中实现了 facebook 登录。
1---->我能够进行facebook登录,但之后登录用户能够继续使用我的应用程序,即出现一个带有三个选项卡项目的tabbarController,同时我需要获取facebook用户详细信息(电子邮件、名字、姓氏等)
但我无法检索详细信息。我不明白我哪里错了。
在我的 ViewController.m 中:
- (IBAction)performLogin:(id)sender
{
AppAppDelegate *appDelegate = (AppAppDelegate *) [[UIApplication sharedApplication] delegate];
[appDelegate openSessionWithAllowLoginUI:YES];
UITabBarController *tabBarController=[[UITabBarController alloc]init];
SearchViewController *searchViewController=[[SearchViewController alloc]initWithNibName:@"SearchViewController" bundle:nil];
UProfile *uprofile=[[UProfile alloc]initWithNibName:@"UProfile" bundle:nil];
userprofile.title=@"My Profile";
LogOut *logout=[[LogOut alloc]initWithNibName:@"LogOut" bundle:nil];
logout.title=@"Sign out";
tabBarController.viewControllers=[NSArray arrayWithObjects:searchViewController,uprofile,logout, nil];
[self presentModalViewController:tabBarController animated:YES];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(sessionStateChanged:)
name:FBSessionStateChangedNotification
object:nil];
}
- (void)sessionStateChanged:(NSNotification*)notification {
if (FBSession.activeSession.isOpen) {
[FBRequestConnection
startForMeWithCompletionHandler:^(FBRequestConnection *connection,
id<FBGraphUser> user,
NSError *error) {
if (!error) {
NSString *fbUserEmail= @"";
NSLog(@"%@",user);
fbUserEmail=[user objectForKey:@"email"];
AppAppDelegate *appDelegate = (AppAppDelegate *) [[UIApplication sharedApplication] delegate];
appDelegate.fbEmail=fbUserEmail;
}
}
];
}
}
但是在这里没有显示 facebook 登录页面,我得到了 tabbarController,我无法检索用户详细信息。
如何先显示 facebook 登录页面,然后显示 tabbarController 和用户详细信息?成功登录 facebook 后,如何在选择第一个 tabitem(对应视图)的 tabbarcontroller 的情况下继续使用我的应用程序?
请帮我解决这个问题...请