react-native-linkedin-sdk - 无法读取未定义的属性“配置"(LinkedInSessionManager.ios.js) [英] react-native-linkedin-sdk - Cannot read property 'configure' of undefined (LinkedInSessionManager.ios.js)

查看:27
本文介绍了react-native-linkedin-sdk - 无法读取未定义的属性“配置"(LinkedInSessionManager.ios.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照此处

这是我的环境的道具:

react 16.0.0-alpha.6
react-native 0.43.3
react-native-linkedin-sdk 0.0.4
XCode 8.3.2

Xcode 项目编译没有问题,但是当我调用下面的 JS 代码时收到错误消息,说明函数 configure 未定义

The Xcode project compiles without issues but I receive an error msg when I invoke the JS code below that the function configure is undefined

这是我的测试代码:

const config = {
  clientID: '<my client id>',
  clientSecret: '<my secret>',
  state: '<my state hash>',
  scopes: 'r_basicprofile',
  redirectUri: '<my redirect URL>'
}
const LISDK = LinkedInSDK.configure(config)

导致错误的代码片段位于 LinkedInSessionManager.ios.js

The code snipped that causes the error is in LinkedInSessionManager.ios.js

...
const LinkedInSDK = {
  configure(config) {
    console.info('LINKEDIN SESSION MANAGER', RNLinkedInSessionManager)
    return RNLinkedInSessionManager.configure(config);
  },
  ...
};

module.exports = LinkedInSDK;

我添加了一个控制台输出来检查我是否得到了一个 RNLinkedInSessionManager 对象但我得到了一个 undefined,这意味着 RNLinkedInSessionManager 的代码项目未连接到 react-native.

I added a console output to check whether I get a RNLinkedInSessionManager object but I get an undefined, which means the code of the RNLinkedInSessionManager project is not connected to react-native.

文件 RNLinkedInSessionManager.xcworkspace 已成功添加到我的 XCode 项目文件夹中 /ios 下,但似乎没有指向该库的链接.

The file RNLinkedInSessionManager.xcworkspace has been successfully added to my XCode project folder under /ios but it seems there is no link to the library.

非常感谢任何帮助.

推荐答案

我放弃了使用 react-native-linkedin-sdk.

相反,我成功实现了这个库 react-native-linkedin-login

Instead I successfully implemented this library react-native-linkedin-login

但是,如果不进行一些修改,该库将无法工作.

Nevertheless the library doesn't work without some modifications.

这是我的发现:

安卓:

我按照所有步骤 这里 但我收到以下错误:

I followed all steps here but I received the following error:

错误:Project :app 声明了从配置 'compile' 到配置 'default' 的依赖关系,但未在 project :react-native-linkedin-login 的描述符中声明.

原来上面说明的路径是错误的.为了解决这个问题,我像这样更新了 settings.gradle 文件中的路径:

It turns out the path described in the above instructions is wrong. To solve the problem I updated the path in the settings.gradle file like that:

//project(':react-native-linkedin-login').projectDir = new File(rootProject.projectDir, '../../android')
project(':react-native-linkedin-login').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linkedin-login/android') 

之后我就可以成功构建项目了.

After that I could successfully build the project.

iOS:

按照描述完成所有步骤后 这里你的XCode项目路径中有一个文件夹RNLinkedinLogin.

After completing all steps as described here you will have a folder RNLinkedinLogin in your XCode project path.

LinkedinLogin.m 文件放入 Build Phases -> Compiled Sources

Drop the LinkedinLogin.m file into the Build Phases -> Compiled Sources

这两个文件都有旧的导入语法,但自从 react native 0.40 及更高版本以来,语法已经改变.您必须相应地编辑这些导入.

Both files have the old import syntax but since react native 0.40 and above the syntax has changed. You must edit these imports accordingly.

更改文件 RNLinkedinLogin.m

 // old syntax
 //#import "RCTEventDispatcher.h"
 // new syntax
 #import <React/RCTEventDispatcher.h>

和文件'RNLinkedinLogin.h`中的导入

and the import in file 'RNLinkedinLogin.h`

 //#import "RCTBridgeModule.h"
 #import <React/RCTBridgeModule.h>

您的项目现在可以正确编译了.

Your project will now compile without errors.

祝你好运,汤姆

这篇关于react-native-linkedin-sdk - 无法读取未定义的属性“配置"(LinkedInSessionManager.ios.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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