Reading time: 1 min

This recipe shows two ways of detecting when your app goes to foreground or background.

NotificationCenter solution

The first solution works on iOS 13+ and any device, iPhone or iPad, and is generally the one you should use. First, add these two extensions to your app:

extension View {
  f...

Continue Reading...

Reading time: 1 min

For whatever reason, stroking (i.e drawing a border) and filling a SwiftUI Shape at the same time is difficult and unintuitive. Shape has methods for both, stroke and fill, respectively, but they both return some View, meaning you can't chain them.

Say you want to do the following:

Screenshot%202021-07-21%20at%2021.02.45

T...

Continue Reading...

Reading time: 4 min

This recipe shows how to perform a GET request in the background using BGTaskScheduler and BGAppRefreshTaskRequest. For whatever reason, this has way too many gotchas:

  • You can't use Alamofire, you have to use URLSession.
  • You can use URLSessionDataTask, it has to be a URLSessionDownl...

Continue Reading...