Xcode react native fbsdk/Facebook iOS SDK-未定义不是对象(正在评估';LoginManager.logInWithReadPermissions';)

Xcode react native fbsdk/Facebook iOS SDK-未定义不是对象(正在评估';LoginManager.logInWithReadPermissions';),xcode,react-native,react-native-fbsdk,Xcode,React Native,React Native Fbsdk,尝试使用react native fbsdk时出错。我假设SDK安装过程中存在一些问题,但我不确定 安装似乎没有错误,但在尝试使用SDK时,我遇到以下错误: undefined is not an object (evaluating 'LoginManager.logInWithReadPermissions') 正在使用SDK的代码: try { var result = await LoginManager.logInWithReadPermissions(["public_prof

尝试使用react native fbsdk时出错。我假设SDK安装过程中存在一些问题,但我不确定

安装似乎没有错误,但在尝试使用SDK时,我遇到以下错误:

undefined is not an object (evaluating
'LoginManager.logInWithReadPermissions')
正在使用SDK的代码:

try {
  var result = await LoginManager.logInWithReadPermissions(["public_profile"]);
  if (result && result.isCancelled) {
    console.log("Login cancelled");
  } else {
    console.log(
      "Login success with permissions: " +
      result.grantedPermissions.toString()
    );
  }
} catch (e) {
  console.error(e.message);
}
安装说明:

npm install react-native-fbsdk
react-native link react-native-fbsdk
cd ios
pod init
// Add "pod 'FacebookSDK'" to pod file
pod install
// Configure Info.plist and AppDelegate.m
此处指定了前两个命令: 此处指定了流程的其余部分:

有人知道会出什么问题吗

谢谢

Environment:
- macOs High Sierra
- XCode (10.1)
- FacebookSDK (4.38.0)
- react (16.6.1)
- react-native (0.57.5)
- react-native-fbsdk (0.8.0)
另一个未解决的问题来自某个人,他似乎有相同的问题,但他没有指定安装过程或软件包版本。
以下是我的安装过程。这是工作

1.安装本机fbsdk
react-native安装react-native fbsdk

2.安装SDK 将以下行添加到
ios/PodFile
并执行
pod安装

pod 'FBSDKLoginKit'
pod 'FBSDKShareKit'
如果没有FBSDKShareKit将生成失败,出现:致命错误:“未找到FBSDKShareKit/FBSDKShareKit.h”文件

3.Set Info.plist 将以下行添加到ios/Project Name/Info.plist(根据)

7.我的环境:
您必须运行react-native-link react-native fbsdk,并检入您的本机项目(ios或android),如果链接成功,则手动执行。 1.转到项目下的库文件,右键单击选择“将文件添加到项目”。然后选择react native fbsdk=>ios=>RCTFBSDK.xcodepro。 2.将libRCTFBSDK.a添加到“链接的Franmework和Librarray”

它应该可以工作,否则请检查您的SDK版本,因为最新版本已经更改了某些内容。

检查此视频可能有助于您解决此问题
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key> 
        <array> 
            <string>fb369704160457623</string> 
        </array> 
    </dict>
</array> 
<key>FacebookAppID</key> 
<string>Your facebook app id</string>
<key>FacebookDisplayName</key> 
<string>Your app name</string>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>
//  AppDelegate.m
#import <FBSDKCoreKit/FBSDKCoreKit.h> // Add this line

- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [[FBSDKApplicationDelegate sharedInstance] application:application
    didFinishLaunchingWithOptions:launchOptions]; // Add this line
  // Add any custom logic here.
  return YES;
}

// Add following lines
- (BOOL)application:(UIApplication *)application 
            openURL:(NSURL *)url 
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {

  BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
    openURL:url
    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
    annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
  ];
  // Add any custom logic here.
  return handled;
}
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity } from 'react-native';
import { LoginManager } from "react-native-fbsdk";

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

type Props = {};
export default class App extends Component<Props> {
  login() {
    LoginManager.logInWithReadPermissions(["public_profile"]).then(
      function (result) {
        if (result.isCancelled) {
          console.log("Login cancelled");
        } else {
          console.log(
            "Login success with permissions: " +
            result.grantedPermissions.toString()
          );
        }
      },
      function (error) {
        console.log("Login fail with error: " + error);
      }
    );
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
        <TouchableOpacity onPress={this.login.bind(this)}>
          <Text>FBLogin</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});
react-native run-ios
  React Native Environment Info:
    Binaries:
      Node: 11.2.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 23.0.3, 24.0.1, 25.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.1, 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.1 => 16.6.1
      react-native: 0.57.7 => 0.57.7
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7
      react-native-rename: 2.3.2