react-native-linkedin-sdk - Cannot read property 'configure' of undefined (LinkedInSessionManager.ios.js)

别说谁变了你拦得住时间么 提交于 2019-12-20 05:29:13

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/43754577/react-native-linkedin-sdk-cannot-read-property-configure-of-undefined-linke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!