gpt4 book ai didi

react-native - 使用 Facebook 登录时不会触发 onLoginFinished 回调

转载 作者:行者123 更新时间:2023-12-04 05:12:33 25 4
gpt4 key购买 nike

我正在构建一个简单的 React Native 应用程序,它使用 react-native-fbsdk 实现“使用 Facebook 登录”
当使用凭据登录时,当按钮从登录更改为注销时,我可以登录和注销,但是 onLoginFinished回调永远不会被触发,尽管 onLogoutFinished工作正常。

这是我的代码:

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>
);
}
};

最佳答案

我想你应该试试这个。

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

把函数改成这个。
onFacebookLoginFinished (error, result){
...
}

关于react-native - 使用 Facebook 登录时不会触发 onLoginFinished 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58257093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com