GithubHelp home page GithubHelp logo

jodybrewster / react-native-linkedin-login Goto Github PK

View Code? Open in Web Editor NEW
71.0 4.0 42.0 3.09 MB

React Native Linkedin login

Objective-C 23.99% C 2.33% Java 67.63% JavaScript 5.10% Python 0.69% Makefile 0.26%
react-native linkedin-sdk android ios linkedin login signin

react-native-linkedin-login's Introduction

react-native-linkedin-login

npm version License Dependency Status Coverage Status Gitter

Let your users sign in with their Linkedin account.

Requirements

  • Node v4+.
  • React Native 0.30+

Installation

iOS Guide

Automatic

First install and save the library

npm install react-native-linkedin-login --save;

Then link the library to your project

react-native link;

In the manual section below you will find updates you need to make to your Info.plist file. Please also refer to the linkedin documentation at the bottom of this readme for more info.

Manual

First install and save the library

npm install react-native-linkedin-login --save

Drag and drop the following xcode project file into the xcode project...

node_modules/react-native-linkedin-login/ios/RCTLinkedinLogin.xcodeproj

Add these lines to your AppDelegate.m

#import <RCTLinkedinLogin/RCTLinkedinLogin.h>
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  if ([RCTLinkedinLogin shouldHandleUrl:url])
  {
    return [RCTLinkedinLogin application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
  }
  return YES;
}

Add the following to your Info.plist, please refer to the Linkedin docs below...

<key>NSAppTransportSecurity</key>
<dict>
	<key>NSExceptionDomains</key>
	<dict>
		<key>linkedin.com</key>  
		<dict>
			<key>NSExceptionAllowsInsecureHTTPLoads</key>
			<true/>
			<key>NSExceptionRequiresForwardSecrecy</key>
			<false/>
			<key>NSIncludesSubdomains</key>
			<true/>
		</dict>
		<key>localhost</key>
		<dict>
			<key>NSExceptionAllowsInsecureHTTPLoads</key>
			<true/>
		</dict>
	</dict>
</dict>
<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<string>li{YOUR_APP_ID_GOES_HERE}</string>
		</array>
	</dict>
</array>
<key>LIAppId</key>
<string>{YOUR_APP_ID_GOES_HERE}</string>
<key>LSApplicationQueriesSchemes</key>
<array>
	<string>linkedin</string>
	<string>linkedin-sdk2</string>
	<string>linkedin-sdk</string>
</array>

Android Guide

Automatic

First install and save the library

npm install react-native-linkedin-login --save;

Then link the library to your project

react-native link;

Manual

First install and save the library

npm install react-native-linkedin-login --save

Then modify the following fules

  • In android/setting.gradle
...
include ':react-native-linkedin-login', ':app'
project(':react-native-linkedin-login').projectDir = new File(rootProject.projectDir, '../../android')

  • In android/app/build.gradle
...
dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile project(":react-native-linkedin-login") // <-- add here
}
  • Register Module (in MainApplication.java)
package com.rnlinkinloginexample;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

import net.jodybrewster.linkedinlogin.RNLinkedinLoginPackage;  // <------ add here

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new RNLinkedinLoginPackage() // <------ add this line to yout MainActivity class
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

Linkedin Getting Started Guide

Check out the following Android guide for reference

Usage

Please change the init with your parameters

...


this.init(
    [
        'r_emailaddress',
        'r_basicprofile'
    ]
).then((e) => {
    console.log('Linkedin initialized');
});

Options For Linkedin Profile Fields

Check out following Linkedin developer guied for profile fields

...

//pass options as string parameters in getProfile()
var options = 'id,first-name,last-name,industry,email-address,industry,location'

LinkedinLogin.getProfile(options)

Additional scopes

Please note that basic and email permissions are hardcoded. Pull requests are welcome! ლ(́◉◞౪◟◉‵ლ)

Alternatives

License

The MIT License (MIT)

Copyright (c) 2015 Jody Brewster

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

react-native-linkedin-login's People

Contributors

dmitrika avatar fjandin avatar getumangon avatar harsha-n avatar jodybrewster avatar kviswanath avatar rickyansari avatar slestang avatar tam-borine avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-linkedin-login's Issues

onActivityResult not invoked after login

Hi! I'm trying to setup the library and everything works fine until I perform the login, because no data is returned.

After take a deep look at the library and add a few traces I've noticed that the onActivityResult method is never called so no result is delivered to the react app.

Any ideas on this? This is my configuration:

{
  "name": "Pikis",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native": "^4.0.0",
    "jest-expo": "~20.0.0",
    "react-test-renderer": "16.0.0-alpha.12"
  },
  "main": "Root.js",
  "scripts": {
    "test": "node node_modules/jest/bin/jest.js --watch"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "^20.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz",
    "react-native-elements": "^0.17.0",
    "react-native-fbsdk": "^0.6.1",
    "react-native-linkedin-login": "^1.44.1",
    "react-navigation": "^1.0.0-beta.11",
    "react-redux": "^5.0.5",
    "redux": "^3.7.2",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.2.0",
    "uuid": "^3.1.0"
  }
}

Thanks

Import syntax has changed for your Objective C file

Hi there,

I implemented your solution into a test project. Here my findings:

Android:
The path described here is wrong. If the path is taken as is this error will appear 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.

The correct path should be:

//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:
I added a console log in the file /android/react-native-linkedin-login/src/LinkedinLogin.js.

constructor() {
   console.log('RNLinkedinLogin', RNLinkedinLogin);
}

I always got an undefined for the RNLinkedinLogin object

Then I thought I might have to compile the LinkedinLogin.m explicitly. So I dropped it into the Build Phases -> Compiled Sources and tried to build the project, which gave me view errors.

After looking into the files I discovered that the import syntax is not correct for react native 0.40 and above.

I 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>

After that I got the project compiled and I got the correct object RNLinkedinLogin

Please update the files accordingly.

Thanks

Android build failed

Hi!

Trying to setup android and can't build it. Failing with following error:

***/node_modules/react-native-linkedin-login/android/src/main/java/net/jodybrewster/linkedinlogin/RNLinkedinLoginPackage.java:29: error: method does not override or implement a method from a supertype
    @Override
    ^
1 error
:react-native-linkedin-login:compileReleaseJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-linkedin-login:compileReleaseJavaWithJavac'.

Any ideas what can be wrong?

"react-native-linkedin-login": "^1.44.1",
"react-native": "0.51.0",

LinkedIn implementation

Hello,
when implementing oAuth (for LinkedIn) inside a React Native WebView Component, Once successfully logged in and the uri-redirect is initiated, how do I trigger and pass the token back into the non-WebView React Native Component or store it asyncStorage for future use. Either using Promises, async/await or any alternative method of delivery.
Thank you.

error: cannot find symbol in PackageList.java

I tried all steps automatic installation as well as manual configuration, but stuck on below error coming from android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java

this import is already available in packagelist.js file

android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:53: error: cannot find symbol
import com.linkedin.android.mobilesdk.RNLinkedinLoginPackage;
                                     ^
  symbol:   class RNLinkedinLoginPackage
  location: package com.linkedin.android.mobilesdk

   /android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:134: error: cannot find symbol
      new RNLinkedinLoginPackage(),
          ^
  symbol:   class RNLinkedinLoginPackage
  location: class PackageList

'RCTLinkedinLogin/RCTLinkedinLogin.h' file not found

Steps to reproduce error:

  1. Create a new project react-native init LNTest

  2. cd into the newly created folder LNTest

  3. Install package npm install --save react-native-linkedin-login

    "react": "16.0.0-alpha.12",
    "react-native": "0.45.0",
    "react-native-linkedin-login": "^1.44.1"
    
  4. Link library react-native link react-native-linkedin-login

  5. Open XCode (8.3.2)

  6. Clean & Build project (succeeded)

  7. Drop RCTLinkedinLogin.xcodeproj into the project

  8. Add #import <RCTLinkedinLogin/RCTLinkedinLogin.h> to AppDelegate.m file

Header Search Path: $(SRCROOT)/../node_modules/react-native-linkedin-login/ios/RCTLinkedinLogin

screenshot 2017-06-08 17 57 21 2

Native Linkedin app login

Hey Jody,

I've setup your library and it's working nicely. I was wondering if it is currently possible to authenticate using the official Linkedin app if it is install on the user device and if not fall back to the web view version? I currently only see the web view version even though I have the official app installed.

Cheers
Tom

Waiting time before dialog "Download LinkedIn App" appears is too long.

Test app with the below packages has been installed on physical devices without Linkedin app installed.

"react": "16.0.0-alpha.12",
"react-native": "0.45.0",
"react-native-linkedin-login": "^1.44.1"

LinkedinLogin is initiated at componentDidMount and the LinkedinLogin.login is invoked on a button click

componentDidMount() {
    LinkedinLogin.init(['r_emailaddress', 'r_basicprofile'])
}

_btnClick() {
    LinkedinLogin.login()
        .then((user) => {
            console.log('User logged in: ', user)
        if(err) {
                console.log('ERROR login to Linkedin', err)
        })
}

The waiting time before the Install Linkedin app dialog appears is very arbitrary. It could be 6 seconds for the first time and up to 5 minutes for the consecutive times. That is a bad user experience.

I'm wondering whether the package could look up the url schema on the actual device to determine whether LinkedIn is installed or not to speed up the process.

Cannot setup the linkedin login

Hi,
I'm trying to use your project on a new project I started.
Because I'm pretty new with react-native, I followed your readme and tried to create my first login page with linkedin based on your example.js file. But without success...
The problem I got when I click on Sign in with Linkedin is generic...

SyntaxError: Unexpected token u in JSON at position 0

Should be great to juste have quick example in the readme.

Bitcode bundle could not be generated ...

The sample project builds and runs fine but it doesn't archive for pushing to App Store (TestFlight) I get the following error msg:

Bitcode bundle could not be generated because ... libRCTLinkedinLogin.a(Pods-dummy.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build for architecture armv7

Env vars

react - 16.0.0-alpha.12
react-native - 0.45.0
react-native-linkedin-login - 1.44.1
Xcode - 8.3.2
iOS - 10.3

LinkedinLogin was called with 1 argument, but expects 5.

I get this error when trying to do linkedin login:

LinkedinLogin was called with 1 argument, but expects 5. Changed this method yourself, this usually means that native code and Java Script code are out of sync.

How to fix that?

Linkedin login not working properly in ios

I am using the below code for integrating Linkedin login, it's working fine in android but not in ios
componentWillMount() {
console.log('init');
LinkedinLogin.init(
[
'r_emailaddress',
'r_basicprofile'
]
);
}
async handleLinkedinLogin(){
LinkedinLogin.login().then((user) => {
this.setState({ user });
this.getUserProfile();
}).catch((e) => {
alert('Error', e);
});
return true;
}
getUserProfile(user) {
LinkedinLogin.getProfile().then((data) => {
const userdata = Object.assign({}, this.state.user, data);
console.log(userdata);
}).catch((e) => {
alert(e);
});
}

<Image source={require('@images/linkedin.png')} style={[styles.img3]}/>

In IOS inside handleLinkedinLogin() function It's taking me inside App store linkedin app, even I have already installed app. And in app store I am clicking linkedin "open" so I am walking inside linkedin application.
I can't come back to me react-native application, with user profile. above same code working fine in android.
screen shot 2018-10-02 at 5 16 33 pm

In image is my developer account setting

Android issue

Image of error

Hey great package! I just tried this package on android by following the instructions but first it throws a compile error due to a naming collision with react native. After deleting the react native folder inside the node_modules folder it compiles, but throws the error in the picture above. Any ideas?

Linker command failed, linkedin sdk does not contain bitcode

Not sure if related.

When I added (copied) RNLinkedinLogin folder into project folder in Xcode, and trying to build it. The project builds successfully when running emulator, but fails with the device. Only by set Enable Bitcode option in General -> Build Settings -> Build Options to No can I resolve the issue.

Below is a screen cast
screen shot 2016-04-16 at 11 18 37 pm

why need clientSecret?

i just for get a token,why need clientSecret?
it's not safe exposure clientSecret,
can you offer a method to get token by client_id

IOSLinkedInAPI main thread issue.

I was getting an error on IOS "Accessing _chachedSystemFence needs main thread". this only happens when user login and perform some tasks e.g (post some thing to server) and then logout. After logout if he tries to login again this above error popped.

To fix this I have update my pods for IOSLinkedInAPI https://github.com/tauqeer-ahmad/IOSLinkedInAPI/blob/master/IOSLinkedInAPI/LIALinkedInHttpClient.m

+dispatch_sync(dispatch_get_main_queue(), ^{ [self.presentingViewController presentViewController:nc animated:YES completion:nil]; +}); to get the main thread.

I'm looking for a way to specify my forked repo path for IOSLinkedInAPI in react-native-linkedin-login podspecs. Any ideas?

No linkedIn App Installed iOS

If I have no app installed on iPhone.
Nothing happend.
I try to debug native but everything what i find out is that LinkedIn SDK returns false for shouldHandleUrl.

Can you help me please?
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog(@"%@ shouldHandle=%@", url, [RCTLinkedinLogin shouldHandleUrl:url] ? @"Yes" : @"No"); if ([RCTLinkedinLogin shouldHandleUrl:url]) { return [RCTLinkedinLogin application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; } return Yes; }

cannot find symbol new RNLinkedinLoginPackage()

/Users/chriscates/projects/meetf2f/android/app/src/main/java/com/meetf2f/MainApplication.java:7: error: cannot find symbol
import com.linkedin.android.mobilesdk.RNLinkedinLoginPackage;
                                     ^
  symbol:   class RNLinkedinLoginPackage
  location: package com.linkedin.android.mobilesdk
/Users/chriscates/projects/meetf2f/android/app/src/main/java/com/meetf2f/MainApplication.java:31: error: cannot find symbol
            new RNLinkedinLoginPackage(),
                ^
  symbol: class RNLinkedinLoginPackage
/Users/chriscates/projects/meetf2f/android/app/src/main/java/com/meetf2f/MainApplication.java:32: error: cannot find symbol
            new RNLinkedinLoginPackage(this),
                ^
  symbol: class RNLinkedinLoginPackage
3 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Here's the dump of the issues... Any reason why the library won't work?

[iOS] After webview login : Authorization failed Error Domain=LIALinkedInERROR Code=2 "(null)"

Hi,

thanks for this very useful plugin. I've successfully used it on Android, but I have some trouble in iOS, at least testing on simulator in Webview. I see the login page, I can identify myself, then it closes the webview and does move forward, with this error on console :

Authorization failed Error Domain=LIALinkedInERROR Code=2 "(null)"

Any idea what could be wrong there?

Thanks

Is this project still maintained?

Hello Jody and all module users - I wonder if you're still active on this project and if people are using it with current RN version. I consider using it and would be glad also to contribute whatever I could but want to understand what is the current status

Cannot evaluate module react-native-linkedin-login

I have followed everything specified in the android setup guide. I am getting the following error

Cannot evaluate module react-native-linkedin-login. Configuration with name 'default' not found.

My package.json looks like the following

{
  "dependencies": {
    "react-button": "^1.2.1",
    "react-native": "^0.20.0",
    "react-native-dialogs": "0.0.13",
    "react-native-facebook-login": "^1.0.3",
    "react-native-file-transfer-android": "0.0.2",
    "react-native-linkedin-login": "^1.2.2",
    "react-native-loading-spinner-overlay": "0.0.6",
    "react-native-modalbox": "^1.3.1",
    "react-native-navbar": "^1.4.2",
    "react-native-parallax": "^0.2.2",
    "react-native-scrollable-tab-view": "^0.4.0",
    "react-native-selectme": "^1.0.0",
    "react-native-vector-icons": "^1.3.3"
  }
}

Any idea why this error will happen? Any help would be great.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.