UPDATE: Answer below.
Implementing Facebook social-auth login, I have the Facebook SDK loaded and have an Angular component that uses it. The code I have is below:
ngOnInit() {
console.log('calling FB.getloginStatus()');
FB.getLoginStatus(s => this.statusFacebook(s));
}
statusFacebook(status) {
console.log('got facebook status', status);
if (status.status === 'connected' && status.authResponse && status.authResponse.userId) {
console.log('facebook is logged in.');
this.login(status.authResponse.userID, status.authResponse.accessToken);
}
else {
console.log('facebook is not logged in');
FB.login(r => this.fbLogin(r));
}
}
fbLogin(response) {
console.log('fbLogin called', response);
}
What I get is that FB.getLoginStatus call works as advertised and the method statusFacebook gets called once the SDK checks in with the mother ship.
The callback tests whether FaceBook is logged in or not and if it is not (the else block) it calls FB.login. The dialog box that allows the user to log in never appears.
If I move the FB.login call to the ngOnInit method the dialog box does appear. (It complains if the user is already logged in but it seems to function).
So my question is why cannot the callback function invoke the login dialog box even though the ngOnInit method can?