FBSDK:无法读取未定义的属性loginwithreadpermissions

eng*_*nws 7 javascript ios react-native fbsdk

我正在使用FBSDK设置React Native项目以进行登录.

这是我到目前为止所做的:

  1. 我跑了 npm install react-native-fbsdk --save
  2. 我跑了 react-native link
  3. 我按照那里提到的每一步:https://developers.facebook.com/docs/facebook-login/ios/
  4. 我使用此视频仔细检查了一下: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)

这是我的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
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

编辑:在我的项目上:

const FBSDK = require('react-native-fbsdk');
const {
  LoginManager,
} = FBSDK;
Run Code Online (Sandbox Code Playgroud)

加:

_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);
      }
    );
  }
Run Code Online (Sandbox Code Playgroud)

和:

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

我错过了什么?

小智 6

我只是解决了同样的错误。出于某种原因,“ react-native链接react-native-fbsdk”已在Android平台上完成,但在ios上尚未完成。

rnpm-install info的Android模块react-native-fbsdk已被链接rnpm-install info链接的react-native-fbsdk ios依赖rnpm-install info的iOS模块react-native-fbsdk已成功链接

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