React Native FBSDK中的AccessToken问题 [英] Issues with the AccessToken in the React Native FBSDK
问题描述
我无法在React Native的 fbsdk
中获取AccessToken.
I am having trouble with my ability to get the AccessToken in the fbsdk
in React Native.
我正在调用Facebook建议的核心:
I am calling the core as suggested by Facebook:
const FBSDKCore = require('react-native-fbsdkcore');
const {
FBSDKAccessToken,
} = FBSDKCore;
在一种情况下,我尝试按照SO此处所述的类似问题建议将令牌写入日志.
And in one scenario I try to write the token in the log as suggested by a similair question stated here on SO.
<View>
<View style={{flex: 1, alignItems: 'center', padding: 50, marginTop: 250}}>
<View>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={
(error, result) => {
if (error) {
alert("login has error: " + result.error);
} else if (result.isCancelled) {
alert("login is cancelled.");
} else {
FBSDKAccessToken.getCurrentAccessToken((token)=> {
console.log(token);
});
Actions.Navigator()
}
}
}
onLogoutFinished={() => {
alert("logout.")}}/>
</View>
</View>
</View>
这给了我红屏未定义不是对象(正在评估FBSDKAccessTokenInterface.getCurrentAccessToken)
This gives me the redscreen "undefined is not an object (evaluating the FBSDKAccessTokenInterface.getCurrentAccessToken)
尝试在应用程序的其他部分中实现类似功能,当然首先要定义const FBSDKAccessToken
,然后调用 userID
(这应该是 FBSDKCore
)如下:
Trying to pull off something similair in other parts of the app, of course defining the const FBSDKAccessToken
first, then calling the userID
(which should be a part of the FBSDKCore
) as:
<Text style={{fontSize: 18, color:colors.General.navtext}}>{FBSDKAccessToken.userID}</Text>
什么也不做,我认为它可以返回已登录用户的userID.另外,如果我尝试在与以下位置相同的位置写出访问令牌:
Yields nothing, where I believed it to return the userID of the logged in user. Also, if I try to write out the accesstoken in that same place as:
<Text style={{fontSize: 18, color:colors.General.navtext}}>{FBSDKAccessToken.getCurrentAccessToken()}</Text>
我得到和以前一样的红色屏幕.
I get the same red screen as before.
我试图查看库的链接,但这甚至引起了进一步的问题.
I tried to look in to the linking of libraries, but that even caused further problem.
因此,因此,我非常困倦,对于出现问题的反馈,我将非常感谢.
Hence, from this, I am pretty stranded and I would really appreciate some feedback on what has gone wrong.
推荐答案
尝试一下.
console.log(token.accessToken.toString());
这篇关于React Native FBSDK中的AccessToken问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!