IPhone. After logging into facebook, UISwitch status is not set to the 'On' in - (void) fbDidLogin method

I implemented Facebook login and checked the status of my access token in

-(void)fbDidLogin 

Now I have a UITableView , where I have a Button switch like UISwitch that turns on if I have an access token. The problem is that when I get an access token

 -(void)fbDidLogin 
Method called

. Here I set the switch button switch, causing

 [self.switch setOn:YES animated:YES]; 

but it does not happen. when I return and open this page again, it will show the correct status, but not when I set it to fbDidLogin . Any guesses why this is happening?

For facebook authentication, it goes beyond the application and comes back, which is probably why this is happening? but I am calling a web service from fbDidLogin and its health.

the code is simple

 - (void)fbDidLogin { [self.switch setOn:YES animated:YES]; } 
+4
source share
1 answer

where u gets the access token for fb, adds a message notification

[[NSNotificationCenter defaultCenter] postNotificationName: @ "fbDidLogin" object: nil];

Now intial fb is used to login

 -(void)fbLogin { [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(fbDidLogin) name:@"fbDidLogin" object:nil]; // some logic for intial fb login page } 

Also in fbDidLogin method add this

 - (void)fbDidLogin { [[NSNotificationCenter defaultCenter]removeObserver:self name:@"fbDidLogin" object:nil]; [self.switch setOn:YES animated:YES]; } 

Here fbDIdLogin will be called as soon as an access token is received

A similar process can be performed to enter the fb system if the access token is zero.

+1
source

Source: https://habr.com/ru/post/1413514/


All Articles