This post has now been deprecated in favor of: TN3135: Low-level networking on watchOS - https://developer.apple.com/documentation/technotes/tn3135-low-level-networking-on-watchos
Prior to watchOS 6 there was no support for low-level networking APIs in watchOS. watchOS 6 does support the use of Network framework, but only in the context of an audio streaming session. Low level networking APIs such at Network framework, BSD Sockets, and socket streams that are used outside the context of an audio stream session on watchOS will not work as expected and may result in inconsistent behavior compared to iOS. If you are not working on an audio app and wanting to utilize Network framework it’s best to do this work on iOS.
For higher level network API functionality, such as making HTTPS requests, my recommendation is to use NSURLSession for HTTPS requests as this continues to work as it always has on watchOS. Note that NSURLSession tasks such as NSURLSessionWebSocketTask and NSURLSessionStreamTask do not work on watchOS as these tasks still considered low level networking APIs. For HTTPS requests I would recommend using NSURLSessionDataTask.
For more information on networking on watchOS, see the following 2019 WWDC session on Streaming Audio on watchOS 6.
Matt Eaton DTS Engineering, CoreOS meaton3@apple.com
Change history:
- 14th May 2021 - Updated to call out that NSURLSessionWebSocketTask and NSURLSessionStreamTask are not supported on watchOS.
This post has been replaced by a shiny new technote, TN3135 Low-level networking on watchOS.
I’ve left the original post here just for the record, but I’ve locked this thread. If you have questions or comments about networking on watchOS, please start a new thread. Make sure to tag it based on the API you’re using, so CFNetwork if you’re using URLSession
or Network if you’re using Network framework.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"