IOS:在未安装应用程序时,LinkedIn登录未重定向到网页

时间:2016-05-12 04:53:15

标签: ios objective-c linkedin-api

我正在尝试将linkedin集成到我的ios应用程序中。我观察到如果未安装应用程序,我的应用程序会显示安装linkedin应用程序,而不是重定向到像facebook和gmail这样的Web浏览器。我想知道weather linkedin支持这种事情,例如,如果没有安装应用程序,则重定向到网页,或者我必须为其编写自定义代码。如果是这样,请帮助我在未安装linkedin应用程序时以及安装时编写自定义代码。 在我的应用程序中集成linkedin sdk之后,我编写了如下代码。

 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];
     NSLog(@"value=%@ isvalid=%@",[session value],[session isValid] ? @"YES" : @"NO");
     NSMutableString *text = [[NSMutableString alloc] initWithString:[session.accessToken description]];
     [text appendString:[NSString stringWithFormat:@",state=\"%@\"",returnState]];
     NSLog(@"Response label text %@",text);
 }
 errorBlock:^(NSError *error) {
     NSLog(@"%s","error called!");
 }
 ];

2 个答案:

答案 0 :(得分:0)

如果您的设备上未安装该应用,则会调用错误阻止,您必须向用户显示您必须从应用商店下载应用的提醒。用户可以单击“否”,然后将使用OAuth登录。

-(void)loginViaLinkedIn
 {
  __weak __typeof(self)weakSelf = self;
[LISDKSessionManager createSessionWithAuth:[NSArray 
arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, nil]
                                     state:@"some state"
                    showGoToAppStoreDialog:YES
                              successBlock:^(NSString *returnState) {

                                  NSLog(@"%s","success called!");
                                  LISDKSession *session = [[LISDKSessionManager sharedInstance] session];
                                  NSLog(@"value=%@ isvalid=%@",[session value],[session isValid] ? @"YES" : @"NO");
                                  [weakSelf getLinkedInDetail];
                              }
                                errorBlock:^(NSError *error) {
                                    NSDictionary * userInfoDic = [error userInfo];
                                    NSString * info = [[userInfoDic allKeys] firstObject];
                                    if([info isEqualToString:@"You need to download the LinkedIn App in order to connect with LinkedIn"] && error.code == 3)
                                    {
                                        [weakSelf loginViaOAuthProtocol];
                                        // Linkedin native app not available , login with OAuth
                                    }
                                    else
                                    {
                                        [weakSelf linkedinAuthenticationResponse:nil error:error];
                                    }
                                }
 ];

 }

答案 1 :(得分:-1)

您可以阅读有关它的官方文档。 “了解移动身份验证用户体验” 根据以下内容,可能会出现几种可能导致不同用户体验的情况:

-Is the LinkedIn application installed on the device?
-Is the user a LinkedIn member?
-Is the user signed into the LinkedIn application on their device?
-Has the user granted your application permission to access their profile?

以下解释所有这些: https://developer.linkedin.com/docs/ios-sdk-auth#ux