Playing media in the background

On iOS, playing audio in the background requires special permissions that you can enable in your app's Capabilities tab. If you enable the Background modes capability, you can select the Audio, Airplay, and Picture in Picture option to make your app eligible for playing audio in the background. The following screenshot shows the enabled capability for playing audio in the background:

If you want to add proper support for background audio playback, there are three features you need to implement:

  • Set up an audio session, so audio continues playing in the background.
  • Submit metadata to the "now playing" info center. ...

Get Mastering iOS 12 Programming - Third 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.