FaceBook登录不起作用根据我的需要

时间:2014-10-11 09:36:05

标签: ios iphone

我正在创建一个应用程序,我在其中执行Facebook登录。我在我的应用程序中使用故事板。 Facebook登录是有效的,当我点击FBLoginView然后登录就会执行。显示确认屏幕但是当我点击确定按钮然后我返回登录页面但我想继续我的主页。在AppDelegate中,我存储用户的数据并使用以下代码:

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user {
AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
appDelegate.firstName = user.first_name;
appDelegate.LastName = user.last_name;
appDelegate.emailID = [user objectForKey:@"email"];
NSMutableArray *data = [NSMutableArray array];
[data addObject:appDelegate.firstName];
[data addObject:appDelegate.LastName];
[data addObject:appDelegate.emailID];
[FBSession.activeSession closeAndClearTokenInformation];
[self didMoveToParentViewController:home];
[self.navigationController pushViewController:home animated:YES];
}

home是HomeViewController的对象。 我怎样才能进入HomeViewController页面。

现在自定义按钮代码是:

- (IBAction)fblogging:(id)sender {
NSArray *permissions = @[@"email",@"user_about_me",@"user_status",@"user_location"];

[FBSession openActiveSessionWithReadPermissions:permissions
                                   allowLoginUI:YES
                              completionHandler:^(FBSession *session,
                                                  FBSessionState status,
                                                  NSError *error) {

                                  if (error) {

                                  } else if (FB_ISSESSIONOPENWITHSTATE(status)) {


                                      [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
                                          if (error) {

                                              NSLog(@"error:%@",error);


                                          }
                                          else
                                          {
                                              NSString *email=[user objectForKey:@"email"];

                                              if (email.length>0) {
                                                  email=[user objectForKey:@"email"];
                                              }

                                              else
                                              {
                                                  email=@"";
                                              }

                                              NSString *userUpdate =[NSString stringWithFormat:@"user_id=%@&fname=%@&lname=%@",email,user.first_name,user.last_name,nil];

                                              NSLog(@" RequestString for get login details: %@",userUpdate); 

                                              // here add ur segue or push view method
                                               [self.navigationController pushViewController:home animated:YES];
                                          }
                                      }];
                                      // [self promptUserWithAccountName];   // a custom method - see below:
                                  }
                              }];

}     在这里输入代码

0 个答案:

没有答案