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.
Is there any change to this with watchOS 8?
I looked into the update status for this on watchOS 8 and as of 17th June 2021, there was no update on this matter for watchOS 8.
Matt, the watchOS 6 release notes here state that "URLSessionWebSocketTask and URLSessionStreamTask are now available for use in watchOS apps. (49779789)”. What gives?