2015-11-16 65 views
0

我正在使用LinkedIn SDK,並試圖用LinkedIn進行身份驗證,但我沒有從LinkedIn獲得回調到我的應用程序。我使用下面的代碼iOS中沒有回調LinkedIn SDK

[LISDKSessionManager createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION, nil] 
             state:nil // @"some state" 
        showGoToAppStoreDialog:YES 
           successBlock:^(NSString *returnState) {} 
           errorBlock:^(NSError *error) {}]; 

我使用Info.plist中正確appId和我所有的包被添加到LinkedIn開發中心。我也嘗試過使用不同版本的SDK。

回答

1

這可能是微不足道的,但在你的問題中,你實際上並沒有在你的回調塊中做任何事情,你只是傳入一個空白塊。

在成功塊中,檢查[[LISDKSessionManager sharedInstance] session]以獲取有效的用戶會話。在錯誤塊,檢查錯誤對象的描述,並在必要時提醒用戶:

[LISDKSessionManager 
createSessionWithAuth:[NSArray arrayWithObjects:LISDK_BASIC_PROFILE_PERMISSION, nil] 
    state:nil 
    showGoToAppStoreDialog:YES 
    successBlock:^(NSString *returnState) { 
     NSLog(@"Success!"); 
     LISDKSession *session = [[LISDKSessionManager sharedInstance] session]; 
    } 
    errorBlock:^(LISDKAuthError *error) { 
     NSLog(@"Error: %@", [error localizedDescription]); 
    } 
]; 

更多的潛在原因,這可能發生:

你的應用程序沒有設置爲App運輸安全正常。設置NSAllowsArbitraryLoads到真正在你的Info.plist的NSAppTransportSecurity設置或白名單的LinkedIn網址:

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>linkedin.com</key> 
     <dict> 
      <key>NSExceptionAllowsInsecureHTTPLoads</key> 
      <true/> 
      <key>NSIncludesSubdomains</key> 
      <true/>     
      <key>NSExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
    </dict> 
</dict> 

另外,還要確保你白名單LinkedIn的URL方案:

<key>LSApplicationQueriesSchemes</key> 
<array> 
    <string>linkedin</string> 
    <string>linkedin-sdk2</string> 
    <string>linkedin-sdk</string> 
</array> 
相關問題