简体   繁体   English

FBSession登录时的奇怪行为

[英]Strange behavior on FBSession login

I am having a hard time trying to login and logout using FBSession 我在尝试使用FBSession登录和注销时遇到了困难

When I run my app, try to call Login Action and Check after, it displays I'm not authenticated, if I close the app, enter again and call Check action again, it shows it is connected... very strange 当我运行我的应用程序时,尝试调用“登录操作并检查”,它显示我未通过身份验证,如果我关闭该应用程序,再次输入并再次调用“检查操作”,则表明它已连接...非常奇怪

there are not a lot of good material out there about this, any tips? 那里没有很多好的材料,有什么提示吗?

  -(IBAction)Check
    {
        if(FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded)
        {
            [lblLoading setText:@"Connected"];
            NSLog(@"Connected");
        }
        else
        {
            [lblLoading setText:@"Not Conn"];
            NSLog(@"No");
        }
    }

    -(IBAction)Logout
    {
        NSLog(@"Logut called");
        [FBSession.activeSession closeAndClearTokenInformation];
        [FBSession.activeSession close];
        FBSession.activeSession = nil;

        self.Check;
    }

    -(IBAction)Login
    {
        NSLog(@"Login called");

        [FBSession openActiveSessionWithAllowLoginUI:YES];

        self.Check;
    }

If you check the login status immediately after logging in, the app is not logged in. You can wait for the Delegate method fbDidLogin to know you have successfully logged in and there start self.Check . 如果您在登录后立即检查登录状态,则该应用程序尚未登录。您可以等待Delegate方法fbDidLogin知道您已成功登录,然后启动self.Check You can also try this by having a third button to just self.Check just after logging in. 您还可以通过第三个按钮进行self.Check 。登录后立即检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM