Я реализовал вход в 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, как я могу продолжить работу с моим приложением с помощью tabbarcontroller с выбранным первым tabitem (соответствующим представлением)?
Пожалуйста, помогите мне разобраться с этой проблемой... Пожалуйста