react-native-linkedin-sdk-无法读取未定义的属性'configure'(LinkedInSessionManager.ios.js) [英] react-native-linkedin-sdk - Cannot read property 'configure' of undefined (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项目编译没有问题,但是当我调用下面的configure
函数未定义的JS代码时,我收到错误消息msg
这是我的测试代码:
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
...
const LinkedInSDK = {
configure(config) {
console.info('LINKEDIN SESSION MANAGER', RNLinkedInSessionManager)
return RNLinkedInSessionManager.configure(config);
},
...
};
module.exports = LinkedInSDK;
我添加了一个控制台输出,以检查是否得到了RNLinkedInSessionManager
对象,但是得到了undefined
,这意味着 RNLinkedInSessionManager 项目的代码未连接到react-native. /p>
文件RNLinkedInSessionManager.xcworkspace
已成功添加到我的/ios
下的XCode项目文件夹中,但是似乎没有链接到库.
非常感谢您的帮助.
我放弃了使用react-native-linkedin-sdk
.
相反,我成功地实现了该库 react-native-linkedin-login
尽管如此,如果不进行一些修改,该库就无法正常工作.
这是我的发现:
Android:
我遵循了所有步骤这里,但出现以下错误:
错误:项目:app声明了从配置编译"到配置默认"的依赖关系,该依赖关系未在项目:react-native-linkedin-login的描述符中声明.
事实证明上述说明中描述的路径是错误的.
为了解决该问题,我像这样更新了settings.gradle
文件中的路径:
//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')
之后,我可以成功构建项目.
iOS:
按照说明完成所有步骤后这里,您的XCode项目路径中将有一个文件夹RNLinkedinLogin
.
将 LinkedinLogin.m 文件拖放到Build Phases
-> Compiled Sources
两个文件均具有旧的导入语法,但由于对本机0.40及更高版本的响应,语法已更改.您必须相应地编辑这些导入.
更改了文件RNLinkedinLogin.m
// old syntax
//#import "RCTEventDispatcher.h"
// new syntax
#import <React/RCTEventDispatcher.h>
以及文件"RNLinkedinLogin.h"中的导入
//#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>
您的项目现在将正确编译.
祝你好运, 汤姆
I have followed all steps described here
Here is props of my environment:
react 16.0.0-alpha.6
react-native 0.43.3
react-native-linkedin-sdk 0.0.4
XCode 8.3.2
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
Here is my test code:
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)
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;
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.
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.
Any help is much appreciated.
I gave up using the react-native-linkedin-sdk
.
Instead I successfully implemented this library react-native-linkedin-login
Nevertheless the library doesn't work without some modifications.
Here my findings:
Android:
I followed all steps here but I received the following error:
Error:Project :app declares a dependency from configuration 'compile' to configuration 'default' which is not declared in the descriptor for project :react-native-linkedin-login.
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:
After completing all steps as described here you will have a folder RNLinkedinLogin
in your XCode project path.
Drop the LinkedinLogin.m file into the Build Phases
-> Compiled Sources
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.
Changed the import in file RNLinkedinLogin.m
// old syntax
//#import "RCTEventDispatcher.h"
// new syntax
#import <React/RCTEventDispatcher.h>
and the import in file 'RNLinkedinLogin.h`
//#import "RCTBridgeModule.h"
#import <React/RCTBridgeModule.h>
Your project will now compile without errors.
Good luck, Tom
这篇关于react-native-linkedin-sdk-无法读取未定义的属性'configure'(LinkedInSessionManager.ios.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!