I have tried URL session requests in the following three ways:
Proxy through iPhone:
Request failure "ErrorDomain =NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline."
Connecting to a known network:
Request successful
Connecting using cellular data:
Request successful
These tests were all conducted on the Apple Watch Series 6 watchOS 9.4. Does "watch-only App "not support URL session request through iPhone Proxy?
Here is my current URL session request handler:
let config = URLSessionConfiguration.ephemeral
config.waitsForConnectivity = true
config.requestCachePolicy = .reloadIgnoringLocalCacheData
config.urlCache = nil
config.allowsCellularAccess = true
config.allowsConstrainedNetworkAccess = true
config.allowsExpensiveNetworkAccess = true
let session = URLSession(configuration: config, delegate: nil, delegateQueue: .main)
let task = session.dataTask(with: url) { (data, response, error) in
guard error == nil else {
print(error!)
self.error = "\(error!)"
return
}
}
task.resume()
Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>