Created
January 30, 2018 23:25
-
-
Save fitomad/fb620741c336b6d87fa89a4468a88a6e to your computer and use it in GitHub Desktop.
Enable iOS app to play sound in background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MARK: - Step 1. Configuration | |
// | |
/* | |
You need to enable one feature in order to allow our app play sounds in *background* mode. | |
Select the Capabilities tab of project's main target, go to Background Modes section and select: | |
**Audio, AirPlay and Picture in Picture | |
*/ | |
// | |
// MARK: - Step 2. Code | |
// | |
// Copy code below at point when you start your audio system or similar. | |
do | |
{ | |
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) | |
} | |
catch | |
{ | |
print("err @ \(#function) -> No se puede establecer la categoría de sonido.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment