首页 > 解决方案 > [未处理的承诺拒绝:TypeError:未定义不是对象(评估'NativeGraphRequestManager.start')]

问题描述

试图在我的应用程序中实现 FBSDK 和 UBER SDK,但它似乎不起作用。我的封面图片不断加载,事件无法通过。

这是我的尝试!这是我的 package.json 文件。

    "react": "^16.4.1",
"react-native": "^0.55.4",
"react-native-calendar-events": "^1.6.1",
"react-native-easy-grid": "^0.1.17",
"react-native-events": "^1.0.7",
"react-native-fbsdk": "^0.7.0",
"react-native-maps": "^0.21.0",
"react-native-uber-rides": "^0.4.3",
"react-native-uber-rides-estimates": "^0.1.0",

这是我对 fb 的声明

const FBSDK = require('react-native-fbsdk');                        
const {
GraphRequest,
GraphRequestManager} = FBSDK;

这是我从 facebook 页面中提取事件的尝试。

getFBEvents = () => {
const infoRequest = new GraphRequest(
    '/' + this.state.fbPageId + '/events',
    {
        accessToken: this.state.fbPageToken,
        parameters: {
            limit: {
                string: '1000'
            },
            time_filter: {
                string: 'upcoming'
            },
            fields: {
                string: 'description,end_time,name,place,id,start_time,ticket_uri'
            }
        }
    },
    (error, result) => {
        if (!error) {
            this.state.fbEventLoaded = true;
            let data = result.data
            RNCalendarEvents.authorizationStatus()
                .then(status => {
                    if (status === 'authorized')
                    {
                        this.saveEvent(data)
                    }
                    else if (status === 'undetermined')
                    {
                        RNCalendarEvents.authorizeEventStore()
                            .then(status => {
                                if (status === 'authorized')
                                {
                                    this.saveEvent(data)
                                }
                            })
                            .catch(error => {
                            });
                    }
                })
                .catch(error => {
                });
        }
    }
);
new GraphRequestManager().addRequest(infoRequest).start();

这是试图从 facebook 页面中提取封面

getFBCoverPhoto = () => {
const infoRequest = new GraphRequest(
    '/' + this.state.fbPageId,
    {
        accessToken: this.state.fbPageToken,
        parameters: {
            fields: {
                string: 'cover'
            }
        }
    },
    (error, result) => {
        if (!error) {
            console.log('result.cover.source:' +result.cover.source)
            this.state.imgSource = result.cover.source
        }
    }
);
new GraphRequestManager().addRequest(infoRequest).start();

试图弄清楚为什么我的数据没有正确提取。我不断收到 NativeGraphRequestManager.start() 的 TypeError,但我似乎无法弄清楚原因。也许我已经按下它太久了,我现在已经脑死了。

任何帮助表示赞赏。谢谢。

标签: javascriptapireact-nativeexporeact-native-fbsdk

解决方案


推荐阅读