问题
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