react-native-linkedin-sdk icon indicating copy to clipboard operation
react-native-linkedin-sdk copied to clipboard

Cannot read property 'configure' of undefined (LinkedInSessionManager.ios.js)

Open dittmarconsulting opened this issue 8 years ago • 10 comments

Hi all,

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.

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.

dittmarconsulting avatar May 03 '17 06:05 dittmarconsulting

I started working with this yesterday, and have been getting the same error triggered by the same lines of code, although--

  1. My configuration looks like this:
screen shot 2017-05-03 at 8 45 12 am

and

  1. I'm passing my clientID, clientSecret, etc. into the LinkedInSDK.signIn function instead of a configure function. (Per the usage section in the Read Me.)

Regardless, I'm still getting the same error triggered by the same lines of code and I'm a little lost on how to go about fixing this.

bethqiang avatar May 03 '17 13:05 bethqiang

I have the same problem. Did someone get it to work?

freework-tech avatar May 17 '17 14:05 freework-tech

@freework-tech I haven't yet. 😢

bethqiang avatar May 17 '17 15:05 bethqiang

@bethqiang: I figured it out: You have to add the two files in the folder RNLinkedInSessionManager to Build Phases -> Compile Sources in your project target settings (drag & drop)

Let me know if it works

freework-tech avatar May 17 '17 15:05 freework-tech

@freework-tech

Your solution doesn't work for me.

I also updated the code by hand in RNLinkedInSessionManager.swift file as suggested but I still get the same error - RNLinkedInSessionManager is undefined

DispatchQueue.main.sync() {
          linkedinHelper.authorizeSuccess({ (lsToken) in
              // Delay is necessary as ViewController is closing.
              DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                  resolve(RNLinkedInSessionManager.tokenToJSON(lsToken))
              }
          }, error: { (error) in
              reject("authorizeSuccessError", error.localizedDescription, error)
          }, cancel: {
              reject("authorizeSuccessCancel", "", nil)
          })
        }

dittmarconsulting avatar May 18 '17 04:05 dittmarconsulting

Merged https://github.com/joonhocho/react-native-linkedin-sdk/pull/11. Sorry guys, I was busy working on something else.

joonhocho avatar Jun 05 '17 07:06 joonhocho

No worries! I'll try again later this week and report back.

bethqiang avatar Jun 06 '17 13:06 bethqiang

Doesn't work for me :-(

dittmarconsulting avatar Jun 09 '17 02:06 dittmarconsulting

I had to use @freework-tech's solution in addition to using the latest version, but things worked!

Re: @freework-tech's solution, this is what my Xcode looked like per that:

screen shot 2017-06-12 at 2 28 49 pm

I ended up deleting the RNLinkedInSessionManager folder (bullet point 4 in the iOS section of the README right before "Usage") after doing this to see what would happen, and it appears it didn't affect the functioning of anything.

bethqiang avatar Jun 12 '17 19:06 bethqiang

@bethqiang @dittmarconsulting It seems like there is no clean solution for these problems, cuz it works for some and doesnt for others. If things are not working, refer to the ExampleApp. I currently don't know exactly how XCode compiles its codes and react-native.

joonhocho avatar Jun 14 '17 05:06 joonhocho