cordova-plugin-advanced-http icon indicating copy to clipboard operation
cordova-plugin-advanced-http copied to clipboard

[Feature] iOS waitsForconnectivity

Open HusFNS opened this issue 4 years ago • 2 comments

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()

HusFNS avatar Sep 17 '20 09:09 HusFNS

Are there any plans to fix this issue?

ghost avatar Sep 29 '20 08:09 ghost

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.

cs-320-dev avatar Sep 29 '20 13:09 cs-320-dev