facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 909 forks source link

onFinishLogin in the LoginButton Component fires once and then nothing #776

Open nastari opened 3 years ago

nastari commented 3 years ago

🐛 Bug Report

That simple.Just log in. He still logs in normally, but on FinishLogin he ran successfully the first time and never again.

To Reproduce

Take the Official Facebook Login component, place a console.log before any onFinishLogin verification and it won't even enter after the first time.

Expected Behavior

Run onFinishLogin every time I log in.

Code Example

  ...
      <LoginButton
        permissions={['public_profile', 'user_photos']}
        onLoginFinished = {async (error, result) => {

        console.log( 'please answer ' )

          if (error) {
          } else if (result.isCancelled) {
            alert('login is cancelled.');
          } else {
            await AccessToken.getCurrentAccessToken();
           console.log('ok')
          }
        }}
        onLogoutFinished={() => console.log('logout.')}
      />
....

Environment

ystem: OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa) CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz Memory: 143.57 MB / 7.66 GB Shell: 5.8 - /usr/bin/zsh Binaries: Node: 12.17.0 - /tmp/yarn--1594926490001-0.4276471296463562/node Yarn: 1.22.4 - /tmp/yarn--1594926490001-0.4276471296463562/yarn npm: 6.14.4 - ~/.nvm/versions/node/v12.17.0/bin/npm Watchman: Not Found SDKs: Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.0 System Images: android-28 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: Not Found Languages: Java: 1.8.0_252 - /usr/bin/javac Python: Not Found npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.1 => 0.63.1 npmGlobalPackages: react-native: Not Found

newby-coder commented 3 years ago

A workaround is to use LoginManager Check https://newbycoder.com/react_native/facebook_login for a basic implementation This issue is mentioned there