简体   繁体   中英

Strange behavior on FBSession login

I am having a hard time trying to login and logout using 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 . You can also try this by having a third button to just self.Check just after logging in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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