通过facebook登录在ios的sdk

问题描述:

我正在使用facebook-ios-sdk-3.10,使用这个SDK我将登录并从FB中获取用户详细信息它对我来说工作正常。通过facebook登录在ios的sdk

这是我uisng

- (IBAction)fbLogin_click:(id)sender 
{ 
    if (AppDelegate.fbsession.state != FBSessionStateCreated) { 
     // Create a new, logged out session. 
     NSArray *permissions = [NSArray arrayWithObjects:@"offline_access", @"email", @"publish_stream", @"read_stream",@"read_friendlists",@"manage_friendlists",@"friends_about_me",@"publish_actions", nil]; 

     // create a session object, with defaults accross the board, except that we provide a custom 
     // instance of FBSessionTokenCachingStrategy 
     AppDelegate.fbsession = [[FBSession alloc] initWithAppID:nil 
                permissions:permissions 
               urlSchemeSuffix:nil 
              tokenCacheStrategy:nil]; 
    } 


    FBSessionLoginBehavior behavior = FBSessionLoginBehaviorForcingWebView; 
    if (AppDelegate.fbsession.state != FBSessionStateCreatedTokenLoaded) { 

     // even though we had a cached token, we need to login to make the session usable 
     [AppDelegate.fbsession openWithBehavior:behavior completionHandler:^(FBSession *session, 
                      FBSessionState status, 
                      NSError *error) { 
      if (error) 
      { 
       NSLog(@"Error"); 
      } 

      [self GetFBUserDetails]; 
     }];  
    } 
} 

-(void) GetFBUserDetails 
{ 
    if (AppDelegate.fbsession.isOpen) 
    { 
     [HUD show:YES]; 
     // fetch profile info such as name, id, etc. for the open session 
     FBRequest *me = [[FBRequest alloc] initWithSession:AppDelegate.fbsession graphPath:@"me"]; 

     self.pendingRequest= me; 

     [me startWithCompletionHandler:^(FBRequestConnection *connection, 
             NSDictionary<FBGraphUser> *user, 
             NSError *error) { 
      // because we have a cached copy of the connection, we can check 
      // to see if this is the connection we care about; a prematurely 
      // cancelled connection will short-circuit here 
      if (me != self.pendingRequest) { 
       return; 
      } 

      self.pendingRequest = nil; 
      //   self.pendingLoginForSlot = -1; 

      // we interpret an error in the initial fetch as a reason to 
      // fail the user switch, and leave the application without an 
      // active user (similar to initial state) 
      if (error) { 

       return; 
      } 

      [AppDelegate.fbsession closeAndClearTokenInformation]; 
      [FBSession.activeSession close]; 
      [FBSession.activeSession closeAndClearTokenInformation]; 
      FBSession.activeSession=nil; 

      [self FacebookCustomerRegister:user]; 
     }]; 
    } 
} 

在这种情况下,一些用户通过电子邮件创建的Facebook帐户,而不是非常交代,当他尝试通过我的应用程序登录的代码就说明点击登录后空屏按钮,没有进一步的行动。我怎么能通知用户“你还没有验证你的FB帐户”,它不会返回到我的应用程序。我怎样才能从那里获取回应?

任何人都可以帮助我吗?

您使用Graph API或FQL查询从Facebook获得的电子邮件地址是经过验证的电子邮件地址。如果一个帐户还没有验证它的电子邮件,但它不可能得到它。

所以当你获取用户信息,如果你没有得到的电子邮件时,你必须得到许可,则用户没有验证,就可以显示一个警告或用户的任何信息有关验证电子邮件和信息

这里

检查更详细Is it possible to check if an email is confirmed on Facebook?

+0

你好请参考这个网页,我添加了屏幕短裤有http://*.com/questions/20946555/facebook-login-via-app-with-unverified-user-account-in -fb – Rajesh

+0

为什么不切换应用程序到safari会清除正确的问题 – Retro