Linkedin iOS身份validation需要启动Linkedin应用程序

我有一个问题整合LinkedIn SDK与我的iOS应用程序。 看来authentication过程要求我下载LinkedIn应用程序来连接LinkedIn。 有没有办法使用sdk而无需下载LinkedIn应用程序? 苹果拒绝了这个原因的应用程序。 我非常感谢有关解决此问题的任何提示。 提前致谢

本页上的其他答案在2015年11月6日,每个都是指iOS9之前的stream程及其最新的SDK 。

使用最新的版本,安装移动应用程序以使单点login过程起作用是一个“要求”。 工作stream程是:

  • 用户在您的应用中指示login过程
  • 您的应用程序使用链接的应用程序SSO过程
  • 您将收到一个回拨,以便在login完成后继续离开。

就iOS应用而言,这是利用SSO的“必需”方式。 但是,在应用程序的移动版本和非移动版本之间共享授权令牌方面存在轻微的解决方法。

我在以下答复中分享了这一点:
https://stackoverflow.com/a/34312931/1804181和
https://stackoverflow.com/a/34451266/1804181
第一个答案的OP已经成功的实现了这个解决scheme。

简单的说:

testing链接的应用程序的存在:

  • 如果它不在那里:直接通过你的应用程序实现OAuth2
  • 如果存在的话:使用它或您的OAuth2实现(您可能会错误地使用他们的应用程序来获得您可能需要的应用程序的任何function之间的链接能力)。

从而避免了要求安装应用程序,但如果它是利用它。

在LinkedIn iOS SDK网站上,它说,它要求用户已经安装了官方LinkedIn应用程序。 您可能可以使用将UIWebViewembedded到应用程序中,并使用OAuth2身份validationstream对用户进行身份validation,并获取必要的授权令牌。 你也可以使用canOpenURL来检查用户是否有LinkedIn应用程序(iOS 9已经改变了它的工作原理),并提示他们安装应用程序。 祝你好运,

一个非常好的博客文章,从本地ios应用程序集成OAuth2login到LinkedIn可以在这里find: http : //www.oodlestechnologies.com/blogs/Linkedin-Integration-in-Native-iOS这是有点过时,但我希望这帮助。

这是在应用程序内的LinkedIn身份validation工作的演示

尝试使用LIExplorer库进行linkedinauthentication和REST API。 它易于使用。 https://github.com/vijayviswas/LIExplorer

无论LinkedIn App安装与否,完整的工作代码。

如果你在你的项目中使用cocoapod比使用 –

pod 'IOSLinkedInAPI', '~> 2.0' 

在您的ViewController.h内添加这些头文件。

 #import <linkedin-sdk/LISDK.h> #import <LIALinkedInHttpClient.h> #import <LIALinkedInApplication.h> #import <AFHTTPRequestOperation.h> @property (nonatomic, strong) LIALinkedInHttpClient *client; 

在你的ViewController.m里面

 - (void)viewDidLoad { [super viewDidLoad]; _client = [self client]; } //ADD THESE METHOD - (void)requestMeWithToken:(NSString *)accessToken { [self.client GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~:(id,first-name,last- name,maiden-name,email-address,formatted-name,phonetic-last-name,location:(country:(code)),industry,distance,current-status,current-share,network,skills,phone-numbers,date-of-birth,main-address,positions:(title),educations:(school-name,field-of-study,start-date,end-date,degree,activities))?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result){ NSLog(@"current user %@", result); }failure:^(AFHTTPRequestOperation *operation, NSError *error){ NSLog(@"failed to fetch current user %@", error); }]; } - (LIALinkedInHttpClient *)client { LIALinkedInApplication *application = [LIALinkedInApplication applicationWithRedirectURL:@"http://linkedin_oauth/success" clientId:LINKEDIN_CLIENT_ID clientSecret:LINKEDIN_CLIENT_SECRET state:@"760iz0bjh9gy71asfFqa" grantedAccess:@[@"r_basicprofile", @"r_emailaddress"]]; return [LIALinkedInHttpClient clientForApplication:application presentingViewController:self.navigationController]; } - (void)loginWithLinkedin { [self.client getAuthorizationCode:^(NSString *code) { [self.client getAccessToken:code success:^(NSDictionary *accessTokenData) { NSString *accessToken = [accessTokenData objectForKey:@"access_token"]; [self requestMeWithToken:accessToken]; } failure:^(NSError *error) { NSLog(@"Querying accessToken failed %@", error); }]; } cancel:^{ NSLog(@"Authorization was cancelled by user"); } failure:^(NSError *error) { NSLog(@"Authorization failed %@", error); }]; // While Using Linkedin iOS SDK or add if-else to check the app installed or not [LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil] state:nil showGoToAppStoreDialog:YES successBlock:^(NSString *returnState) { NSLog(@"%s","success called!"); LISDKSession *session = [[LISDKSessionManager sharedInstance] session]; } errorBlock:^(NSError *error){ NSLog(@"%s","error called!"); } 

在Linkedin App设置页面中添加上面的URL。

授权redirecturl: http:// linkedin_oauth /成功

我希望这对你们有帮助。