Home > database >  Implement Facebook Messenger login feature with React Native
Implement Facebook Messenger login feature with React Native

Time:12-08

I have 2 apps, the first app (1) like Facebook, the other (2) like Facebook Messenger. I want to implement feature login on (2) app - login with just one click "Continue as [UserName]"; any idea?

CodePudding user response:

When using react-navigation, there is a short guide on how to implement authentication flows in an RNApp. If this is not what your looking for pls consider editing your question to be more detailed/specific.

CodePudding user response:

You should use this package react-native-fbsdk-next:

You'll end up with something like that:

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

export default class Login extends Component {
  render() {
    return (
      <View>
        <LoginButton
          onLoginFinished={
            (error, result) => {
              if (error) {
                console.log("login has error: "   result.error);
              } else if (result.isCancelled) {
                console.log("login is cancelled.");
              } else {
                AccessToken.getCurrentAccessToken().then(
                  (data) => {
                    console.log(data.accessToken.toString())
                  }
                )
              }
            }
          }
          onLogoutFinished={() => console.log("logout.")}/>
      </View>
    );
  }
};
  • Related