Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FBSDKLoginButtonDelegate not triggering delegate methods

Tags:

ios

facebook

Login and Logout is working correctly. According to Facebook

"Your app can get notifications of login results or logout events. To do this assign a delegate to FBSDKLoginButton that confirms to FBSDKLoginButtonDelegate protocol."

I've added the FBSDKLoginButtonDelegate to my view controller which has the following property:

@property (weak, nonatomic) IBOutlet FBSDKLoginButton *FacebookButton;

and the .m (implementation) file has:

@interface firstVC ()
<FBSDKLoginButtonDelegate>

@end

but the problem is that the FBSDKLoginButtonDelegate is not calling:

- (void)  loginButton:  (FBSDKLoginButton *)loginButton
didCompleteWithResult:  (FBSDKLoginManagerLoginResult *)result
                error:  (NSError *)error{

    NSLog(@"facebook login button test");


}

and on logout is not calling:

- (void) loginButtonDidLogOut:(FBSDKLoginButton *)loginButton{
  NSLog(@"facebook logout button test");
}

Additionally I have declared the aforementioned methods in the header between @interface and @end

like image 595
ConfusedDeer Avatar asked May 22 '15 03:05

ConfusedDeer


1 Answers

I had to make sure the button's class was FBSDKLoginButton instead of UIButton, which I had already done:

@property (weak, nonatomic) IBOutlet FBSDKLoginButton *FacebookButton;

Once I did that and implemented the two aforementioned classes in the question, then the fix was to set the button delegate to self on viewDidLoad in the implementation file:

[FacebookButton setDelegate:self];
like image 145
ConfusedDeer Avatar answered Sep 19 '22 10:09

ConfusedDeer