我有一个关于react-native-fbsdk LoginManager的问题。我一直收到错误,“无法读取未定义的属性'loginWithReadPermissions‘。
我尝试了在其他帖子中找到的多种解决方案,但似乎都不能解决我的问题。
我成功地安装了ed react-native-fbsdk,并正确地将FBSDK框架导入到Xcode项目中。我还正确地链接了libRCTFBSDK.a文件。这样做之后,我的构建结果是成功的,但我一直收到错误消息"LoginManager未定义“。
有没有人能帮我一下?
下面是我使用LoginManager和LoginButton编写的代码:
import React from 'react';
import { Container, Content, Text, Button, View } from 'native-base';
import Loading from './Loading';
import { AccessToken, LoginManager, LoginButton } from 'react-native-fbsdk';
class Login extends React.Component {
constructor(props) {
super(props);
}
onLoginFacebook = () => {
LoginManager
.logInWithReadPermissions(["public_profile", "email"])
.then((result) => {
if(result.isCancelled) {
return Promise.reject(new Error("The user cancelled the request"));
}
console.log(`Login success with permissions: ${result.grantedPermissions.toString()}`);
//get the access token
return AccessToken.getCurrentAccessToken();
})
.then((data) => {
const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken);
return firebase.auth().signInWithCredential(credential);
})
.then((currentUser) => {
console.log(`Facebook Login with user : ${JSON.stringify(currentUser.toJSON())}`);
})
.catch((error) => {
console.log(`Facebook Login fail with error: ${error}`);
});
}
render() {
const {
loading,
error,
success,
locale,
} = this.props;
const { email } = this.state;
if (loading) return <Loading />;
return (
<Container style={{backgroundColor: 'white'}}>
<Content>
<View padder>
<Button
containerStyle={{
padding: 10,
width: 150,
margin: 20,
borderRadius: 4,
backgroundColor: 'rgb(73, 104, 173)',
}}
style={{marginTop: 20}}
onPress={this.onLoginFacebook}
>
<Text style={{fontSize: 18, color: 'white'}}>
Login Facebook
</Text>
</Button>
</View>
</Content>
</Container>
);
}
}
export default Login;以下是xCode配置的截图:


发布于 2019-01-17 15:57:26
我遇到了同样的错误,经过长时间的搜索,我发现我必须降级到SDK版本4.38.0 (当时我使用的是v4.39.0 )。
安装之前的版本后,一切都像预期的那样工作。希望能有所帮助。
https://stackoverflow.com/questions/54192247
复制相似问题