cordova-plugin-advanced-http
cordova-plugin-advanced-http copied to clipboard
[Feature] iOS waitsForconnectivity
Is your feature request related to a problem? iOS14 has waitsForconnectivity option and timeout settings this is needed for calls to local network connections
Describe the solution you'd like Check the following link for more information https://lostmoa.com/blog/GettingReadyForNewiOS14LocalNetworkPrivacyRestrictions/ I would like to be able to set this dynamically per call by default the timeoutIntervalForResource should be 60 seconds.
let sessionConfig = URLSessionConfiguration.default
sessionConfig.waitsForConnectivity = true
sessionConfig.timeoutIntervalForResource = 60
URLSession(configuration: sessionConfig)
.dataTask(with: URLRequest(url: url)) { data, response, error in
if let response = response as? HTTPURLResponse {
print("Response code: \(response.statusCode)")
}
if let error = error {
print(error.localizedDescription)
}
}.resume()
Are there any plans to fix this issue?
We solved the issue by this way:
diff --git a/src/ios/AFNetworking/AFURLSessionManager.m b/src/ios/AFNetworking/AFURLSessionManager.m
index af01bda..0c98b44 100644
--- a/src/ios/AFNetworking/AFURLSessionManager.m
+++ b/src/ios/AFNetworking/AFURLSessionManager.m
@@ -514,6 +514,7 @@ - (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)config
}
self.sessionConfiguration = configuration;
+ self.sessionConfiguration.waitsForConnectivity = true; // compatibility with iOS 14
self.operationQueue = [[NSOperationQueue alloc] init];
self.operationQueue.maxConcurrentOperationCount = 1;
Not sure about possible side-effects, but at least it works with our App.