title: AVAudioSession setCategory Swift 4.2 iOS 12 - Play Sound on Silent
body: <p>To play sound even on Silent mode I use to use below method. But how it's not working.</p>
  
  <pre><code>// Works on Swift 3  
  do {
      try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
  } catch {
      print(error)
  }
  </code></pre>
  
  <p>How to get it work in 4.2 / iOS 12?</p>
  
  <p>In newer version we need to set mode and options.</p>
  
  <pre><code>try AVAudioSession.sharedInstance().setCategory(
      &lt;#T##category:AVAudioSession.Category##AVAudioSession.Category#&gt;,
      mode: &lt;#T##AVAudioSession.Mode#&gt;, 
      options: &lt;#T##AVAudioSession.CategoryOptions#&gt;)`
  </code></pre>