I am getting this
"load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled""
when trying to call the api in my custom framework. but when I run the same code in another project, it works fine and give the proper response. below is my code. Is there anything I have to do in custom framework which does not require in normal project.
func invokePostWebServiceCallLogin(request : String,param : NSDictionary,completion : @escaping (_ webResponse : WebserviceResponseClass) ->Void) -> Void {
let headers = [
"Accept": "application/json",
"Content-Type": "application/x-www-form-urlencoded"
]
let passingParameter : [ String : AnyObject] = param as! [String : AnyObject]
UIApplication.shared.isNetworkActivityIndicatorVisible = true
WebServiceHelperClass.Manager.request(URL(string: request)!, method: .post, parameters: passingParameter,encoding: URLEncoding.default, headers: headers).validate().responseJSON {
response in
UIApplication.shared.isNetworkActivityIndicatorVisible = false
switch response.result {
case .success:
let webResult = WebserviceResponseClass()
webResult.isSuccess = true
webResult.responseData = response.data as NSData?
webResult.error = nil
completion(webResult)
break
case .failure(let error):
let webResult = WebserviceResponseClass()
webResult.isSuccess = false
webResult.responseData = nil
webResult.error = error as NSError
completion(webResult)
}
}
}
private static var Manager : Alamofire.SessionManager = {
let serverTrustPolicies: [String: ServerTrustPolicy] = [
"dev.xxxxx.com": .pinCertificates(
certificates: ServerTrustPolicy.certificates(),
validateCertificateChain: true,
validateHost: true
),
"xx.xx.xxx.xx": .disableEvaluation
]
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 45
configuration.timeoutIntervalForResource = 45
let manager = Alamofire.SessionManager(
configuration: configuration,
serverTrustPolicyManager: ServerTrustPolicyManager(policies: serverTrustPolicies)
)
return manager
}
Task <91C7555E-F6E6-45EB-9762-EE61915719DE>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://dev.xxxxxxxx.com:xxxx/api/VirtualAPI/Login, NSErrorFailingURLKey=https://dev.xxxxxxxx.com:xxxx/api/VirtualAPI/Login, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <91C7555E-F6E6-45EB-9762-EE61915719DE>.<1>" ), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <91C7555E-F6E6-45EB-9762-EE61915719DE>.<1>, NSLocalizedDescription=cancelled} [-999]