onLoginFinished callback is not fired in Login with Facebook

react-native-fbsdk
react-native-fbsdk logout
react-native facebook login cancelled
react-facebook sdk
react native facebook share
react-native-fbsdk pod
facebook app events react native
react native social login

I'm building a simple React Native app which implements "Login with Facebook" using react-native-fbsdk I can login and logout as the button changes from Log in to Log out when logging with credentials, but the onLoginFinished callback never gets fired, though onLogoutFinished works properly.

Here is my code:

import React, { Component } from 'react';
import { View,Alert,Button,Text } from 'react-native';
import { LoginButton, AccessToken } from 'react-native-fbsdk';

export default class Login extends Component {
  constructor(props) {
    super(props);
    this.state = {
      userInfo: null
    }
  }

  onFacebookLoginFinished = (error, result) => {
    if (error) {
      Alert.alert("login has error: " + result.error);
    } else if (result.isCancelled) {
      Alert.alert("login is cancelled.");
    } else {
      AccessToken.getCurrentAccessToken().then(
        (data) => {
          Alert.alert(data.accessToken.toString())
          this.props.navigation.navigate('Home')
        }
      )
    }
  }

  render() {
    return (
      <View>
        <LoginButton
          onLoginFinished={this.onFacebookLoginFinished}
          onLogoutFinished={() => Alert.alert("logout.")}/>
      </View>
    );
  }
};

I think you should try this.

onLoginFinished={(error, result) => this.onFacebookLoginFinished(error, result)}

Change the function into this.

onFacebookLoginFinished (error, result){
    ...
}

onLoginFinished never is fired · Issue #687 · facebook/react-native , onLogoutFinished is called, but not onLoginFinished. Though the button's Using the LoginManager (as shown here) does invoke the correct callback please refer : https://reactnativecode.com/facebook-login-integration/  1 onLoginFinished callback is not fired in Login with Facebook Oct 23 '19 1 Drop down not expanding on click because onChange won't fire Nov 10 '19 1 Statement works but will not re-direct?

Change the onLoginFinished method from:

onLoginFinished={this.onFacebookLoginFinished}

To:

onLoginFinished={(error, result) => this.onFacebookLoginFinished(error, result)}

Hope this Helps!

Facebook SDK for React Native FAQ & Troubleshooting, How do I handle the "FBSDKShareKit/FBSDKShareKit.h file not found" error? When a user clicks the LoginButton they see the standard Facebook login page only get a blank page and my onLoginFinished callback never gets triggered. Pavindu. Undergraduate of FIT,UoM 3 onLoginFinished callback is not fired in Login with Facebook Oct 6 '19. Facebook; Twitter;

Could you try this code?

Try doing it yourself in a function.

onLoginFinished={(error, data) => {
               if (error) {
      Alert.alert("login has error: " + result.error);
    } else if (result.isCancelled) {
      Alert.alert("login is cancelled.");
    } else {
      AccessToken.getCurrentAccessToken().then(
        (data) => {
          Alert.alert(data.accessToken.toString())
          this.props.navigation.navigate('Home')
        }
      )
    }
          }}

Login - React Native SDK, This guide provides examples of using the Facebook Login Button and Login login for your app, copy the following code into a file called FBLoginButton.js . When the login has completed, the function you provide for the onLoginFinished​  We're working to update facebook.com and the Help Center. If you don't see instructions for the version you're using, learn how to switch versions or report a problem.

You're accessing the component instance (this), so you'll need to bind to your onLoginFinished function, perefarbly in your constructor, i.e.

constructor(props) {
  super(props);
  this.state = {
    userInfo: null
  }

  this.onFacebookLoginFinished = this.onFacebookLoginFinished.bind(this);
}

See further explanation and more options here: https://reactjs.org/docs/faq-functions.html#bind-in-constructor-es2015

React Native SDK, How do I handle the "FBSDKShareKit/FBSDKShareKit.h file not found" error? My React Native application is working with the Facebook SDK, but when I try to log an I'm trying to use auto-login to reload an expired token or request one they only get a blank page and my onLoginFinished callback never gets triggered. Fired when the authResponse object has changed, which indicates that the user's access token has changed in some way. auth.statusChange. string. Fired when the user's Facebook Login status changes. auth.login. string. Fired when someone logs into the app using FB.login(). It is preferable to use the auth.statusChange event for this purpose

Can't get accesstoken when facebook app is installed with target , (android). <!-- react-native-fbsdk is a wrapper around the Facebook SDKs for iOS and Android. I tried logout and login again, but still onLoginFinished not fired. Log into Facebook to start sharing and connecting with your friends, family, and people you know.

How to check if the user is already logged in? - react-native - html, I am complete new to react-native and Facebook sdk So I have followed the tutorial given If the user is logged in, the onLoginFinished not called. Is there any perticular callback to check that? or any other method or some workaround? Here is the Login button: <LoginButton onLoginFinished={ (error, result) => { this. 2) If you want to keep the Facebook SDK in your app, refer to the directions in the GitHub repo. Permalink My React Native application is working with the Facebook SDK, but when I try to log an event, like activateApp, I get the error: "AppEventsLogger.activateApp is not a function."

Example of Facebook Sign In integration in React Native, Integration of login via Facebook feature in React Native App. How to add app in feature) but the library in the stable branch does not support the same so here we have </Text> <LoginButton readPermissions={['public_profile']} onLoginFinished={(error, But when building the Application I encountered an issue called In Theodhor Pandeli's first post for SitePoint, he looks at integrating the Facebook API into Android apps for login, profile information and posting.

Comments
  • But arrow functions are not needed to bind, are they?
  • but why? they are arrow fuctions in the first place
  • @Pavindu Good point. I don't know the inner workings of React well enough, but at the moment, your approach is described 'experimental and not standardized' in the docs: reactjs.org/docs/…
  • @eronisko Thanks for pointing that out. I am also not very well aware of React. I didn't know about that.