【问题标题】:facebook sdk logout issue for iosios的facebook sdk注销问题
【发布时间】:2014-07-24 21:53:21
【问题描述】:

我第一次使用 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”。但是我没有让其他用户登录的选项。

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

【问题讨论】:

    标签: facebook-ios-sdk


    【解决方案1】:

    没有像 ios 中的网站那样的会话,因此您必须从 Safari 中退出 Facebook 帐户,然后才能再次登录。据我所知,我回答了你的问题。

    【讨论】:

      猜你喜欢
      • 2011-09-07
      • 2012-02-25
      • 1970-01-01
      • 2011-05-19
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多