Usage is simple, just import "LinkedInHelper.h" to your controller where you want to use this library:
If you want to login user with LinkedIn Api, so you can easily fetch your informations like below:
#import "LinkedInHelper.h"
@implementation ViewController
- (void)fetchUserInformations {
LinkedInHelper *linkedIn = [LinkedInHelper sharedInstance];
linkedIn.cancelButtonText = @"Close"; // Or any other language But Default is Close
NSArray *permissions = @[@(BasicProfile),
@(EmailAddress),
@(Share),
@(CompanyAdmin)];
linkedIn.showActivityIndicator = YES;
#warning - Your LinkedIn App ClientId - ClientSecret - RedirectUrl
//takes the authentication from a LinkedInService-Info.plist which must be in your bundle.
//That way credentials don't get mixed up with code. See the header on how to create it.
//If you really want, there is also a variant where you pass the clientId, -secret & redirectUrl directly but thats only ok for small projects :) */
[linkedIn requestMeUsingConfigWithSenderViewController:self
permissions:permissions
State:nil
successUserInfo:^(NSDictionary *userInfo) {
// Whole User Info
NSLog(@"user Info : %@", userInfo);
}
failUserInfoBlock:^(NSError *error) {
NSLog(@"error : %@", error.userInfo.description);
}
];
}
@end
You can check if LinkedIn Access Token is still valid like below:
- (BOOL)isLinkedInAccessTokenValid {
return [LinkedInHelper sharedInstance].isValidToken;
}
You can fetch user Informations automatically without getting authorization code again via web view. This will automatically fetch use informations thanks to valid access token
- (void)getUserInfo {
LinkedInHelper *linkedIn = [LinkedInHelper sharedInstance];
// If user has already connected via linkedin in and access token is still valid then
// No need to fetch authorizationCode and then accessToken again!
#warning - To fetch user info automatically without getting authorization code, accessToken must be still valid
if (linkedIn.isValidToken) {
// So Fetch member info by prior access token
[linkedIn autoFetchUserInfoWithSuccess:^(NSDictionary *userInfo) {
// Whole User Info
NSLog(@"user Info : %@", userInfo);
} failUserInfo:^(NSError *error) {
NSLog(@"error : %@", error.userInfo.description);
}];
}
}
For more information please check the Demo App. I tried to do my best in code by writing well documentation.
This library requires a deployment target of iOS 6.0 or greater.
LinkedinIOSHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'LinkedinIOSHelper', '~> 1.0.7'
- Share on LinkedIn
- Apply with LinkedIn
- Manage Company Pages
- Special thanks to IOSLinkedInAPI, this library helped me much about how to connect Linkedin Rest API.
Ahmet Kazım Günay, ahmetkgunay@gmail.com
LinkedinIOSHelper is available under the MIT license. See the LICENSE file for more info.