Working with an internet connection on iOS with Swift: Best practices

Click for: original source

Networking is an integral part of most iOS applications. A common network-related task is Internet connectivity detection. Written by Vadim Bulavin.

The most popular answers on how to detect network connectivity status on iOS suggest using SCNetworkReachability. In this article, let’s discuss why this solution is less than optimal, and lay out best practices of working with the Internet connection recommended by Apple. Apple says that we should not check Internet connection before firing an HTTP request.

The article’s content is split into this parts:

  • Checking connectivity before firing an HTTP request
  • Disabling or enabling app features based on network connectivity status
  • Attaching constraints to network operations, e.g., disabling large file download via cellular

We liked: Do not enable or disable app features based on an Internet connection. Instead, indicate connectivity status on UI, and diagnose network errors. Great read!

[Read More]

Tags swiftlang web-development app-development how-to