Networking with URLSession

Learn how to use URLSession, Apple's networking API, including when and how to use data, download and upload tasks, with or without a custom session delegate, and how the system manages background sessions and WebSockets. Leverage the Combine API and SwiftUI to take your networking to the next level. Updated for iOS 13 and Swift 5.2. By Brian Moakley.

4.5 (15) · 3 Reviews

Download materials
Save for later
Share

Who is this for?

Intermediate developers. You should be comfortable with the Swift programming language and up to speed on the SwiftUI framework. You should also have some working knowledge of the Combine framework.

You'll start by getting an overview of concurrency then you'll learn how to make simple network requests. Later, you'll learn how to download and upload files and how to set up background sessions. Ultimately, you'll leverage the power of the Combine framework to make your requests.

Finally, you'll learn about authentication, Apple's Transport Security and reading and writing cookies.

Covered concepts

  • URLSession Configuration
  • URLSession Connections
  • Downloading Files
  • Uploading Data
  • Pausing, Resuming and Canceling Data
  • Showing Network Progress
  • Simulating Different Network Speeds
  • Vapor Framework
  • Background Downloading
  • WebSockets
  • URLSession and Combine
  • Authentication
  • Application Transport Security
  • Cookies

Part 1: Concurrency and DataTasks

1
Toggle description

Learn about the URLSession and how the framework evolved in the way that it did. Also learn about the course goals.

Toggle description

Get an overview of why concurrency is important and how ignoring it can create a terrible user experience.

Toggle description

In this episode, get a brief overview of the various options in iOS and see them in action.

Toggle description

This challenge will put your understanding of concurrency to the test by updating the user interface from an operation queue.

Toggle description

Learn the basics of Session Configuration and how you can use the configuration to modify your session's behavior.

Toggle description

This episode covers the basics of working with sessions and how to use session data tasks to fetch remote data.

Now that you have an idea of how to create a session, your challenge is to create your own session and fetch artwork from over the network.

Conclusion 1:56
Toggle description

Review the concepts covered in this part and preview the next part of the course.

Part 2: Downloading and Uploading

Toggle description

Now that you understand the data task, learn how to put the download task and upload task to use.

Working with tasks often means setting priorities and figuring out what to cache. This episode covers what you need to know.

Toggle description

In this episode, put the download task to use by downloading music from iTunes preview API.

Toggle description

Put your downloading skills to the test by downloading some album artwork and displaying it on the screen.

Toggle description

In this episode, learn how to display download progress as a file is downloaded.

Toggle description

You have lots of different tools to simulate poor network connections. This episode will show you a few of them.

Toggle description

This episode covers the process of pausing, canceling and resuming downloads.

Toggle description

Vapor is an open source server written entirely in Swift. In this episode, learn how to install the server.

Toggle description

Learn how to upload data to a local vapor instance.

Conclusion 1:45
Toggle description

This episode concludes the part on downloading and uploading, but things are just starting to get interesting

Part 3: Background Downloading and WebSockets

Toggle description

This episode introduces the concept of background downloading and WebSocket communication.

Toggle description

Learn about the background task, how to use one of them and then how to handle background events.

Toggle description

This episode gives you an overview of BSD sockets and explains how Apple's Networking framework works for you.

Toggle description

Use the new WebSocket task to connect a local Vapor server to send messages and then use them to create a chat server.

Conclusion 0:52
Toggle description

Review all the concepts covered in this part and then learn about upcoming topics.

Part 4: URLSession and Combine

Toggle description

Combine is a native reactive framework that released with iOS 13. Learn how URLSession has been updated to use it.

Toggle description

This episode provides an overview of the general concepts behind the Combine framework.

Toggle description

Learn how to use a data task with Combine and then how to access the data through a variety of operators.

Toggle description

With the use of Zip, learn how to group multiple requests together.

Toggle description

Learn how to make a urlrequest once another request has finished.

Toggle description

Put your Combine skills to the test by fetching a list of album titles and printing the results out to a list.

Toggle description

Learn how handle errors when something goes wrong during URLSession

Conclusion 0:49
Toggle description

This concludes this part on Combine but there's more to learn in the final part of this course.

Part 5: Authentication, ATS and Cookies

Toggle description

This final part of the course covers a variety of important topics that you will need to know when making network requests.

Toggle description

This episode covers the various different ways to provide authentication when working with URLSession.

Toggle description

iOS provides some important security mechanisms when making requests on iOS. This episode shows how ATS can affect your app.

Toggle description

Learn how read cookies and write cookies from a URLSession

Toggle description

In this challenge, learn print cookies from raywenderlich.com

Conclusion 2:04
Toggle description

This final episode concludes the course while providing several resources on where to learn more about URLSession.