2016-04-15 14 views
0

能夠啓動的應用程序來創建會話,但登錄後應用程序中的LISDKSessionManager succuess塊不會被調用無法在IOS爲LinkedIn創建登錄會話

[LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_FULL_PROFILE_PERMISSION, nil] 
             state:nil 
         showGoToAppStoreDialog:YES 
            successBlock:^(NSString *returnState) { 
             if(returnState){ 
             NSLog(@"%s","success called!"); 

             } 
             if (returnState) { 
              [self updateControlsWithResponseLabel:YES]; 
             } 
             // 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); 
             _responseLabel.text = text; 
             self.lastError = nil; 
             // retain cycle here? 
             [self updateControlsWithResponseLabel:NO]; 

            } 
            errorBlock:^(NSError *error) { 
             NSLog(@"%s %@","error called! ", [error description]); 
             self.lastError = error; 
             // _responseLabel.text = [error description]; 
             [self updateControlsWithResponseLabel:YES]; 
            } 
    ]; 
+0

是否調用了'errorBlock'?如果是的話,是否說錯誤? – Larme

+0

沒有errorBlock不被調用 – Akshay0309

回答

0

最後注意到linkedInS DK登錄只適用於iPhone而不適用於iPad

0

在你的AppDelegate

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 
    { 
    return [LISDKCallbackHandler application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; 
    } 

和在你的按鈕操作方法中調用這個

NSArray *permissions = [NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, nil]; 
    [LISDKSessionManager createSessionWithAuth:permissions state:nil showGoToAppStoreDialog:YES successBlock:^(NSString *returnState) 
    { 
     NSLog(@"%s","success called!"); 
     LISDKSession *session = [[LISDKSessionManager sharedInstance] session]; 
     NSLog(@"Session : %@", session.description); 
    } errorBlock:^(NSError *error) 
    { 
    NSLog(@"%s","error called!"); 
    }]; 

    // call this to fetch basic information os user logged in 
    -(void) getRequest:(NSString*)token 
    { 

    [[LISDKAPIHelper sharedInstance] getRequest:@"https://api.linkedin.com/v1/people/~" 
            success:^(LISDKAPIResponse *response) 
     { 
     NSData* data = [response.data dataUsingEncoding:NSUTF8StringEncoding]; 
     NSDictionary *dictResponse = [NSJSONSerialization JSONObjec tWithData:data options:NSJSONReadingMutableContainers error:nil]; 
     NSLog(@"Authenticated user name : %@ %@", [dictResponse valueForKey: @"firstName"], [dictResponse valueForKey: @"lastName"]); 
     } 
    error:^(LISDKAPIError *apiError) 
    { 
     NSLog(@"Error : %@", apiError); 
    }]; 
    } 
+0

即使在這段代碼中沒有成功或錯誤塊被調用,我在AppDelegate和按鈕操作中都設置了調試器,AppDelegate調試器甚至沒有被調用 – Akshay0309

+0

您的info.plist文件是否正確?您需要設置LIAppID,並在LSApplicationQueriesSchemes中添加這兩個「linkedin-sdk」和「linkedin-sdk2」。 –

+0

是的,我已經檢查了這些東西 – Akshay0309