我正在使用来自 Linkedin 版本 1.0.2 的新 iOS SDK 并获得回调超时。目的是对社交帐户进行身份验证,然后将其链接到现有的内部帐户,或者从社交信息创建新的内部用户。一切正常,但不是 100% 的时间。有时在 60 秒后回调发生超时。安装链接的应用程序时会发生这种情况。有任何想法吗?
@IBAction func linkedin(sender: AnyObject) {
LISDKSessionManager.createSessionWithAuth([LISDK_BASIC_PROFILE_PERMISSION, LISDK_EMAILADDRESS_PERMISSION], state: nil, showGoToAppStoreDialog: true, successBlock: { (string) -> () in
if (LISDKSessionManager.hasValidSession()) {
LISDKAPIHelper.sharedInstance().getRequest("\(Constants.linkedinBaseURL)/people/~:(id,firstName,lastName,email-address)", success: { (response) -> () in
dispatch_async(dispatch_get_main_queue(), { () -> () in
if let dataFromString = response.data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) {
let result = JSON(data: dataFromString)
LISDKSessionManager.clearSession()
var socialMember = SocialMember()
socialMember.socialType = SocialType.linkedin
socialMember.id = result["id"].stringValue
socialMember.email = result["emailAddress"].stringValue
socialMember.firstName = result["firstName"].stringValue
socialMember.lastName = result["lastName"].stringValue
Loader.setOnView(self.view, withTitle: "Loading...", animated: true)
self.socialLink(socialMember, completion: { () -> () in
Loader.hideFromView(self.view, animated: true)
})
}
})
}, error: { (error) -> () in
LISDKAPIHelper.sharedInstance().cancelCalls()
LISDKSessionManager.clearSession()
println(error)
})
}
}, errorBlock: { (error) -> () in
LISDKAPIHelper.sharedInstance().cancelCalls()
LISDKSessionManager.clearSession()
println(error)
})
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
if (LISDKCallbackHandler.shouldHandleUrl(url)) {
return LISDKCallbackHandler.application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}
return false
}
60 秒后回调错误
2015-08-05 15:24:05.500 xxx[34640:7245029] lisdksession 管理器 openURL 调用!,
Error Domain=LISDKAuthError Code=2 "The operation couldn't be completed. (LISDKAuthError error 2.)"UserInfo=0x174a6a3c0 {errorDescription=The request timed out., originalDomain=LISDKNetworkUnavailableError, errorInfo=NETWORK_UNAVAILABLE}
最佳答案
检查您是否在 .plist 文件中添加了应用程序 ID 中的链接。关键是“LIAppId”。并将应用程序 ID 添加到 urlscheme 中作为“li”。
关于ios - 适用于 iOS 的 Linkedin Mobile SDK - 回调超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31843938/