Independent Apple Watch app can't connect to Internet.

My device is Apple Watch Series 5. It only support wifi.
When I was debug in real machine. It can't connect to internet. The app is independent. But the system app can connect to internet.
Why? Why? Why? And How to solve.




code :
Code Block   
let session = URLSession.shared
    let task: URLSessionDataTask = session.dataTask(with: URLRequest(url: URL(string: "https://www.baidu.com/s?wd=iOS")!)) { [self] (data, response, error) in
      if data == nil {
         
        print(error.debugDescription)
      }
    }
    task.resume()



error message :

Code Block
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>, NSLocalizedDescription=The Internet connection appears to be offline., _kCFStreamErrorCodeKey=50, _NSURLErrorRelatedURLSessionTaskErrorKey=(
  "LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>",
  "LocalDataPDTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>",
  "LocalDataTask <FD086BDC-3051-469F-9280-0054CC8F0488>.<1>"
), NSErrorFailingURLStringKey=https://www.baidu.com/s?wd=iOS, _kCFStreamErrorDomainKey=1, NSErrorFailingURLKey=https://www.baidu.com/s?wd=iOS})

  • I had the same issue,have you solved it?or anybody else can help?

Add a Comment

Replies

Do you solved problem finally? I had the same problems.

Try to shutdown you iphone, you will found that, you apple watch now can connect to the network. I think this is a bug.

https://www.v2ex.com/t/816834