FBSDK:无法读取未定义的属性loginwithreadpermissions [英] FBSDK: Cannot read property loginwithreadpermissions of undefined

查看:389
本文介绍了FBSDK:无法读取未定义的属性loginwithreadpermissions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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


  1. 我跑 npm install react-native-fbsdk --save

  2. 我跑了 react-native link

  3. 我按照那里提到的每一步:



    编辑:在我的项目上:

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

    加:

      _onFBButtonPress(){
    LoginManager.logInWithReadPermissions(['public_profile'])。then(
    function(result){
    if(result.isCancelled){
    alert('Login canceled');
    } else {
    alert('登录成功与权限:'
    + result.grantedPermissions.toString());
    }
    },
    函数(错误){
    alert('登录失败,错误:'+错误);
    }
    );
    }

    并且:

     < 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 info iOS模块react-native-fbsdk已成功链接



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


    I'm setting up a React Native project using the FBSDK for login purpose.

    Here's what I've done so far:

    1. I ran npm install react-native-fbsdk --save
    2. I ran react-native link
    3. I followed each step mentioned there: https://developers.facebook.com/docs/facebook-login/ios/
    4. I double checked using this video: https://www.youtube.com/watch?v=rAXVKapP5cM

    However, I still get this red screen error:

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

    Here's my AppDelegate.m content:

    #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
    

    Here's my linked frameworks and binaries:

    EDIT: on my project:

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

    Plus:

    _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);
          }
        );
      }
    

    And:

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

    What do I miss?

    解决方案

    I just resolved the same error. For some reason "react-native link react-native-fbsdk" had finished for Android but not ios.

    rnpm-install info Android module react-native-fbsdk is already linked rnpm-install info Linking react-native-fbsdk ios dependency rnpm-install info iOS module react-native-fbsdk has been successfully linked

    Try rerunning and make sure you are linking with libRCTFBSDK.a

    这篇关于FBSDK:无法读取未定义的属性loginwithreadpermissions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆