async function facebookLogin() {
  try {
    const result = await LoginManager.logInWithPermissions(['public_profile', 'email']);

    if (result.isCancelled) {
      // handle this however suites the flow of your app
      throw new Error('User cancelled request');
    }

    console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);

    // get the access token
    const data = await AccessToken.getCurrentAccessToken();

    if (!data) {
      // handle this however suites the flow of your app
      throw new Error('Something went wrong obtaining the users access token');
    }

    // create a new firebase credential with the token
    const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);

    // login with credential
    const firebaseUserCredential = await firebase.auth().signInWithCredential(credential);

    console.warn(JSON.stringify(firebaseUserCredential.user.toJSON()))
  } catch (e) {
    console.error(e);
  }
}
// Calling the following function will open the FB login dialogue:
Calling the following function will open the FB login dialogue.
Calling the following function will open the FB login dialogue .
async function facebookLogin() {
  try {
    const result = await LoginManager.logInWithPermissions(['public_profile', 'email']);
    if (result.isCancelled) {
      throw new Error('User cancelled request');
    }
    console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);
    const data = await AccessToken.getCurrentAccessToken();
    if (!data) {
      throw new Error('Something went wrong obtaining the users access token');
    }
    const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
    const firebaseUserCredential = await firebase.auth().signInWithCredential(credential);
    console.warn(JSON.stringify(firebaseUserCredential.user.toJSON()))
  } catch (e) {
    console.error(e);
  }
}
async function facebookLogin ( ) { try { const result = await LoginManager . logInWithPermissions ( [ 'public_profile' , 'email' ] ) ; if ( result . isCancelled ) { throw new Error ( 'User cancelled request' ) ; } console . log ( ` ${ result . grantedPermissions . toString ( ) } ` ) ; const data = await AccessToken . getCurrentAccessToken ( ) ; if ( ! data ) { throw new Error ( 'Something went wrong obtaining the users access token' ) ; } const credential = firebase . auth . FacebookAuthProvider . credential ( data . accessToken ) ; const firebaseUserCredential = await firebase . auth ( ) . signInWithCredential ( credential ) ; console . warn ( JSON . stringify ( firebaseUserCredential . user . toJSON ( ) ) ) } catch ( e ) { console . error ( e ) ; } }
Calling the following function will open the FB login dialogue:
Calling the following function will open the FB login dialogue :
// handle this however suites the flow of your app // get the access token // handle this however suites the flow of your app // create a new firebase credential with the token // login with credential