2016-12-02 250 views
4

我目前正在为我的Reach Native应用程序设置Facebook身份验证。在react-native-fbsdk安装程序的常见问题后,现在Facebook应用程序事件工作和LoginManager加载。FB SDK错误:登录失败(react-native)

我的问题:授权后LoginManager重定向我回应用程序,然后显示我的错误:

Login Failed

我用很标准的LoginManager实现:

const FBSDK = require('react-native-fbsdk'); 
const { 
    LoginManager, 
    AccessToken, 
} = FBSDK; 


export default class FacebookAuth extends Component { 

    facebook(){ 
    LoginManager.logInWithReadPermissions(['public_profile', 'email']).then(
    function(result) { 
    if (result.isCancelled) { 
     alert('Login cancelled'); 
    } else { 
     alert('Login success with permissions: ' 
     +result.grantedPermissions.toString()); 
    } 
    }, 
    function(error) { 
    alert('Login fail with error: ' + error); 
    } 
); 

你有什么指针给我?

我已经检查:在Info.plist中

  • 的iOS捆绑ID

    • FB应用信息在Facebook应用
    • 客户端的OAuth设置
    • FBSDK LoginButton(同样的错误)

    我正在运行的版本:iOS 10 & react-native 0.38.0。

    谢谢!

  • 回答

    7

    Error when login with Facebook SDK — React Native

    The problem was that Facebook SDK was still keeping the previous session token, and when I was trying to login again I was getting this error, to solve this problem all I had to do was to call the logOut method from the LoginManager.

    尝试将此LoginManager.logInWithReadPermissions...

    LoginManager.logOut();