Making Network Requests on Apple Watch

Fortunately, networking on watchOS is incredibly easy. In traditional Apple fashion, “it just works.” We can use the NSURLSession class to make network requests, download files in the background, and upload files. If you want to use a third-party networking library, such as AFNetworking or Alamofire, you can use them just as on iOS, so long as they use NSURLSession and not its predecessor, NSURLConnection.[8] One thing that’s transparent to us as watchOS app developers is the actual device used to perform network requests. If the watch’s paired iPhone is connected, NSURLSession connections will use the iPhone as a proxy. Otherwise, the watch will connect to known Wi-Fi networks and perform the request ...

Get Developing for Apple Watch, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.