FBSDK:无法读取属性loginwithreadpermissions的undefined

我正在使用FBSDK设置一个React Native项目用于login目的。

以下是我迄今为止所做的:

  1. 我运行npm install react-native-fbsdk --save
  2. 我运行了react-native link
  3. 我遵循这里提到的每一步: https : //developers.facebook.com/docs/facebook-login/ios/
  4. 我再次检查使用此video: https : //www.youtube.com/watch?v = rAXVKapP5cM

不过,我仍然得到这个红色的屏幕错误:

Cannot read property logInWithReadPermissions of undefined在FBLoginManager.js第77行( https://github.com/facebook/react-native-fbsdk/blob/master/js/FBLoginManager.js ) Cannot read property logInWithReadPermissions of undefined

这是我的AppDelegate.m内容:

 #import "AppDelegate.h" #import <FBSDKCoreKit/FBSDKCoreKit.h> #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h> @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *jsCodeLocation; jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"PegaseBuzzApp" initialProperties:nil launchOptions:launchOptions]; rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new]; rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; return YES; } - (void)applicationDidBecomeActive:(UIApplication *)application { [FBSDKAppEvents activateApp]; } - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } @end 

这是我的链接框架和二进制文件:

在这里输入图像说明

编辑:在我的项目上:

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

加:

 _onFBButtonPress () { LoginManager.logInWithReadPermissions(['public_profile']).then( function(result) { if (result.isCancelled) { alert('Login cancelled'); } else { alert('Login success with permissions: ' +result.grantedPermissions.toString()); } }, function(error) { alert('Login fail with error: ' + error); } ); } 

和:

 <Button onPress={() => this._onFBButtonPress()} buttonStyle={'buttonFb'} labelStyle={'buttonFbText'} label={I18n.t('Login.btnConnectFB')}></Button> 

我错过了什么?

我刚刚解决了同样的错误。 出于某种原因,“react-native link react-native-fbsdk”已经为Android完成,而不是ios。

rnpm-install info Android模块react-native-fbsdk已链接rnpm-install info链接react-native-fbsdk ios依赖关系rnpm -install信息iOS模块react-native-fbsdk已成功链接

尝试重新运行,并确保您正在与libRCTFBSDK.a链接