Skip to content

Commit 6822d38

Browse files
committed
initial commit
1 parent 1072d6b commit 6822d38

13 files changed

+656
-2
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# OS
2+
.DS_Store
3+
14
# Logs
25
logs
36
*.log
@@ -35,3 +38,12 @@ jspm_packages
3538

3639
# Optional REPL history
3740
.node_repl_history
41+
42+
# Android
43+
*.iml
44+
android/.idea/
45+
android/gradle/wrapper/
46+
android/build
47+
android/gradlew
48+
android/gradlew.bat
49+
android/local.properties

README.md

+147-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,147 @@
1-
# react-native-linkedin-sdk
2-
React Native Wrapper for Latest LinkedIn Mobile SDK for Sign-In / Auth and API Access.
1+
# React Native Wrapper for Latest LinkedIn Mobile SDK for Sign-In / Auth and API Access.
2+
3+
React Native wrapper for the latest [LinkedIn SDK](https://developer.linkedin.com/docs/android-sdk).
4+
5+
For iOS, this library bridges [tonyli508/LinkedinSwift](https://github.com/tonyli508/LinkedinSwift).
6+
7+
## Getting started
8+
9+
See [Tested Environments](#tested-environments).
10+
11+
`$ react-native install react-native-linkedin-sdk`
12+
13+
14+
## Android
15+
Download the latest release of [LinkedIn's Mobile SDK for Android](https://developer.linkedin.com/downloads#androidsdk).
16+
17+
Move `li-android-sdk/linkedin-sdk` to `{YourApp}/android/linkedin-sdk`.
18+
19+
20+
Follow instructions from [Official Guide](https://developer.linkedin.com/docs/android-sdk) to:
21+
- [Create an application on LinkedIn](https://www.linkedin.com/secure/developer?newapp=).
22+
- Generate a key hash value.
23+
- Configure package name and hash values on your [LinkedIn application settings](https://www.linkedin.com/developer/apps).
24+
25+
Add to your `{YourApp}/android/settings.gradle`:
26+
```
27+
include ':linkedin-sdk' // Add this
28+
```
29+
30+
Add to your `{YourApp}/android/app/build.gradle`:
31+
32+
```
33+
dependencies {
34+
compile project(':linkedin-sdk') // Add this
35+
}
36+
```
37+
38+
39+
## iOS
40+
Follow instructions from [Official Guide](https://developer.linkedin.com/docs/ios-sdk) to:
41+
- [Create an application on LinkedIn](https://www.linkedin.com/secure/developer?newapp=), if haven't done it for Android already.
42+
- [Configure your app on LinkedIn](https://www.linkedin.com/developer/apps).
43+
- Configure your application's Info.plist.
44+
- Important! Do not add `Whitelisting LinkedIn Custom Schemes`. See the [reason](https://github.com/tonyli508/LinkedinSwift/issues/22).
45+
46+
47+
Install [tonyli508/LinkedinSwift](https://github.com/tonyli508/LinkedinSwift):
48+
- Add `pod 'LinkedinSwift', '~> 1.6.6'` to your `{YourApp}/ios/Podfile`.
49+
- Run `pod install` under `{YourApp}/ios`.
50+
51+
52+
Add to your `{YourApp}/ios/{YourApp}/AppDelegate.m`:
53+
```
54+
- (BOOL)application:(UIApplication *)application
55+
openURL:(NSURL *)url
56+
sourceApplication:(NSString *)sourceApplication
57+
annotation:(id)annotation {
58+
if ([LinkedinSwiftHelper shouldHandleUrl:url]) {
59+
return [LinkedinSwiftHelper application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
60+
}
61+
62+
// ... your code
63+
64+
return YES;
65+
}
66+
```
67+
68+
69+
Add to your `{YourApp}/ios/{YourApp}/AppDelegate.h`:
70+
```
71+
#import <LinkedinSwift/LSHeader.h>
72+
```
73+
74+
75+
76+
## Usage
77+
```javascript
78+
import LinkedInSDK from 'react-native-linkedin-sdk';
79+
80+
// later in your code...
81+
async yourMethod() {
82+
const token = await LinkedInSDK.signIn({
83+
// https://developer.linkedin.com/docs/oauth2
84+
85+
// iOS (Required)
86+
// The "API Key" value generated when you registered your application.
87+
clientID: 'your_client_id',
88+
89+
// iOS (Required)
90+
clientSecret: 'your_client_secret',
91+
92+
// iOS (Required)
93+
// A unique string value of your choice that is hard to guess. Used to prevent CSRF.
94+
state: 'some_state_value',
95+
96+
// iOS, Android (Required)
97+
scopes: [
98+
'r_basicprofile',
99+
'r_emailaddress',
100+
'w_share',
101+
],
102+
103+
// iOS (Required)
104+
// The URI your users will be sent back to after authorization. This value must match one of the defined OAuth 2.0 Redirect URLs in your application configuration.
105+
// e.g. https://www.example.com/auth/linkedin
106+
redirectUri: 'your_oauth2_redirect_url',
107+
});
108+
109+
const profile = await LinkedInSDK.getRequest('https://api.linkedin.com/v1/people/~?format=json');
110+
111+
console.log(token, profile);
112+
}
113+
```
114+
115+
116+
## Tested Environments
117+
118+
I only tested with the following environments:
119+
- Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) / Target: x86_64-apple-macosx10.9
120+
- Xcode Version 8.2.1 (8C1002)
121+
- Android Studio 2.2.3 / Build #AI-145.3537739, built on December 2, 2016 / JRE: 1.8.0_112-release-b05 x86_64 / JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
122+
123+
124+
## LICENSE
125+
```
126+
MIT License
127+
128+
Copyright (c) 2017 Joon Ho Cho
129+
130+
Permission is hereby granted, free of charge, to any person obtaining a copy
131+
of this software and associated documentation files (the "Software"), to deal
132+
in the Software without restriction, including without limitation the rights
133+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
134+
copies of the Software, and to permit persons to whom the Software is
135+
furnished to do so, subject to the following conditions:
136+
137+
The above copyright notice and this permission notice shall be included in all
138+
copies or substantial portions of the Software.
139+
140+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
141+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
142+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
143+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
144+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
145+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
146+
SOFTWARE.
147+
```

android/build.gradle

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "23.0.1"
6+
7+
defaultConfig {
8+
minSdkVersion 16
9+
targetSdkVersion 22
10+
versionCode 1
11+
versionName "1.0"
12+
ndk {
13+
abiFilters "armeabi-v7a", "x86"
14+
}
15+
}
16+
17+
lintOptions {
18+
abortOnError false
19+
}
20+
}
21+
22+
dependencies {
23+
compile project(':linkedin-sdk')
24+
compile "com.facebook.react:react-native:+"
25+
}

android/src/main/AndroidManifest.xml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.reactlibrary.linkedsdk">
3+
4+
</manifest>

0 commit comments

Comments
 (0)