title: How do I override silent mode and play sound in notification extension?
body: <p>I am trying to achieve something like find my iPhone app. Even when in the killed state it will play sound at full volume.
  I don't want to use VOIP calls to do it because my app doesn't need it so it might get rejected.</p>
  <p>Here's what I'm trying to do:</p>
  <pre><code>override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -&gt; Void) {
      self.contentHandler = contentHandler
      bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
      var audioPlayer = AVAudioPlayer()
      
      let songTitle = &quot;ping&quot;
      let songExtension  = &quot;mp3&quot;
      
      
      if let url = Bundle.main.url(forResource: &quot;\(songTitle)&quot;, withExtension: &quot;\(songExtension)&quot;)  {
          
          let volumeView = MPVolumeView()
          if let view = volumeView.subviews.first as? UISlider{
              view.value = 1.0 //---0 t0 1.0---
              
          }
          
          do {
              let data = try Data(contentsOf: url)
              try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback, options: .mixWithOthers)
              
              try AVAudioSession.sharedInstance().setActive(true)
              
              audioPlayer = try AVAudioPlayer(data: data, fileTypeHint: AVFileType.mp3.rawValue)
              audioPlayer.volume = 1.0
              audioPlayer.prepareToPlay()
              audioPlayer.play()
          } catch let error {
              print(&quot;[SoundPlayer] There was an error: \(String(describing: error))&quot;)
          }
          
          if (audioPlayer.isPlaying) {
              audioPlayer.stop()
          }
          audioPlayer.play()
      }
      
      if let bestAttemptContent = bestAttemptContent {
          // Modify the notification content here...
          bestAttemptContent.title = &quot;\(bestAttemptContent.title) [modified]&quot;
          
          contentHandler(bestAttemptContent)
          
          
      }
  }
  </code></pre>
  <p>Whenever I try to debug the app I get a crash with error:
  <strong>Error Domain=NSOSStatusErrorDomain Code=561015905 &quot;(null)&quot;</strong></p>