错误:未定义不是对象(评估“NativeGraphRequestManager.start")-react-native-fbsdk(Android)
有人知道怎么解决吗?请帮助!控制台错误:
Does anyone know how to solve it? Help please! Console error:
Events.js//当我 onPress 出现错误.我想我的问题就在这里.
Events.js //When i onPress appear the error. I think that my issue is here.
import React, { Component } from 'react';
import { Image, StyleSheet, View, TouchableOpacity, Text } from 'react-native';
const FBSDK = require('react-native-fbsdk');
const {
GraphRequest,
GraphRequestManager,
} = FBSDK;
class Eventos extends Component {
getInfo() {
const infoRequest = new GraphRequest(
'/me',
null,
this.responseInfoCallback,
);
new GraphRequestManager().addRequest(infoRequest).start();
}
responseInfoCallback(error, result) {
if (error) {
alert('Error fetching data: ' + error.toString());
} else {
alert('Success fetching data: ' + result.toString());
}
}
render() {
return (
<View>
<TouchableOpacity
onPress={() => this.getInfo()}
>
<Text>GetInfo</Text>
</TouchableOpacity>
</View>
);
}
}
export default Eventos;
MainActivity.java
MainActivity.java
public class MainActivity extends ReactActivity {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}
@Override
protected String getMainComponentName() {
return "reactnavigationdrawer";
}
}
MainApplication.java//我觉得还行.
MainApplication.java //I think its okey.
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new FBSDKPackage(mCallbackManager)
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
AppEventsLogger.activateApp(this);
SoLoader.init(this, /* native exopackage */ false);
}
}
package.json//我是否在使用过时的库?
package.json // Am i using deprecated libraries maybe?
{
"name": "BealegendApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"firebase": "^4.8.2",
"lodash": "^4.17.4",
"react": "16.0.0-alpha.12",
"react-native": "^0.46.4",
"react-native-fbsdk": "^0.7.0",
"react-native-responsive-image": "^2.2.0",
"react-native-side-menu": "^1.1.3",
"react-native-textinput-effects": "^0.4.2",
"react-native-vector-icons": "^4.5.0",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.1.0",
"eslint-config-rallycoding": "^3.2.0",
"jest": "20.0.4",
"react-native-vector-icons": "^4.5.0",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
这是一个应用程序,它必须向 facebook graph api 发出请求.当我 onPress 出现错误:未定义不是一个对象(评估'NativeGraphRequestManager.start')"我不知道为什么.请帮忙!!
This is an app that it has to do a request to facebook graph api. When i onPress appear the error: "Undefined is not an object (evaluating 'NativeGraphRequestManager.start')" I dont know why. Help please!!
如果您需要更多代码或详细信息,请告诉我!谢谢!
if you need more code or details tell me! Thanks!
错误:您需要一个 accesToken 才能使用 Graph.在示例中没有定义 accessToken.
Error: You need an accesToken before to use Graph. In the exaple accessToken isn't defined.
要获得它,您必须使用 facebook(LoginButton 组件)登录.之后,您可以通过道具发送此令牌并在您想要的地方发出请求.
To get it you must login with facebook (LoginButton component). After, you can send this token through props and make request where you want.
它适用于您可以在链接中找到的配置(在答案中):
It works with the configuration that you can find in the link (in the answer):