facebook sdk注销ios的问题

时间:2014-07-14 14:13:07

标签: facebook-ios-sdk

我第一次使用facebook sdk for ios。我一直面临着一个奇怪的问题。该 facebook sdk让我退出但不会让我与其他用户登录。你们有任何想法如何解决这个问题。

我正在粘贴我用于退出的东西..

- (IBAction)buttonTouched:(id)sender
{
  // If the session state is any of the two "open" states when the button is clicked
  if (FBSession.activeSession.state == FBSessionStateOpen
      || FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {

    // Close the session and remove the access token from the cache
    // The session state handler (in the app delegate) will be called automatically


      NSHTTPCookie *cookie;
      NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
      for (cookie in [storage cookies])
      {
          NSString* domainName = [cookie domain];
          NSRange domainRange = [domainName rangeOfString:@"facebook"];
          if(domainRange.length > 0)
          {
              [storage deleteCookie:cookie];
          }
      }






    [FBSession.activeSession closeAndClearTokenInformation];

  // If the session state is not any of the two "open" states when the button is clicked
  } else {
    // Open a session showing the user the login UI
    // You must ALWAYS ask for public_profile permissions when opening a session
    [FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
                                       allowLoginUI:YES
                                  completionHandler:
     ^(FBSession *session, FBSessionState state, NSError *error) {

         [[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
             if (error) {
                 NSLog(@"error:%@",error);
             } else {

                 NSLog(@"user dictionary %@",user);
                 // retrive user's details at here as shown below
                 NSLog(@"FB user first name:%@",user.first_name);
                 NSLog(@"FB user last name:%@",user.last_name);
                 NSLog(@"FB user birthday:%@",user.birthday);
                 NSLog(@"FB user location:%@",user.location);
                 NSLog(@"FB user username:%@",user.username);
                 NSLog(@"FB user gender:%@",[user objectForKey:@"gender"]);
                 NSLog(@"email id:%@",[user objectForKey:@"email"]);
                 NSLog(@"location:%@", [NSString stringWithFormat:@"Location: %@\n\n",
                                        user.location[@"name"]]);

             }
         }];

       // Retrieve the app delegate
       AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
       // Call the app delegate's sessionStateChanged:state:error method to handle session state changes
       [appDelegate sessionStateChanged:session state:state error:error];
     }];
  }
}

我在注销后第二次登录“你已经授权Myappname”的文本。但我没有得到其他用户登录的选项。

任何帮助将不胜感激。提前谢谢。

1 个答案:

答案 0 :(得分:0)

ios中的网站没有类似的会话,所以你必须从safari注册Facebook帐户,然后再次登录。我从你的问题中了解到我的答案。