WWDC19
=================
Session materials: https://developer.apple.com/videos/play/wwdc2019/712/
- User preference to minimize data usage
- Explicit signal to reduce network data use
- Per wifi and cellular network
- Background tasks are deferred in this mode
- Background app refresh is also disabled
-
Try large/prefetch with
allowsConstrainedNetworkAccess = false
-
On failure with
error.networkUnavailableReason == .constrained
try low data mode alternative here -
Set
prohibitConstrainedPaths
onNWParameters
-
Check
isExpensive
inNWPath
.debounce()
.removeDuplicates
.filter {}
.map {}
.sink()
DataTaskPublisher
- Single value publisher
- Similar to
URLSession.dataTask
.tryCatch {} .tryMap {} .retry(1) .replaceError(with) .receive(on: Thread) .assign(to)
- Two-way communication over TLS/TCP connection
- Works with Firewalls and CDNs
- Proxy support
-
Compatible with URLSessionTask
-
Server-> NWListener
-
Client-> URLSessionWebSocketTask
-
Webkit -> Javascript Websocket
-
URLSession -> URLSessionWebSocketTask
- Supports authentication and cookies
-
Network.framework -> Webseocket Connection & Listener
-
Cross-layer mobility detection is built into URLSession and Network.framework
-
Rethink
SCNetworkReachability
usage -
Control access with
allowsExpensiveNetworkAccess = false
- Apple maps and music are now also using this technology as Siri to have a better transition between cellular & wi-fi