title: Swift 3 how to override silent mode and play audio from background
body: <p>I am trying to write an app which works like phone finder but with completely different usages and channel of invocation. I am able to get user's location and do background fetch alright but the thing I am struggling with is to play sound on loud volume (Even when phone is silent) to find user's phone when they have lost it in the house. It was all easy on Android and I will like to replicate this on iOS as well. I was able to play sound when the app switches from foreground to background by doing this:</p>
  
  <pre><code>func setupAudio(){
          print("Trying to play audio")
          guard let sound = NSDataAsset(name: "FeelinGood") else {
              print("asset not found")
              return
          }
  
  
          do {
              try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
              try AVAudioSession.sharedInstance().setActive(true)
  
              audioPlayer = try AVAudioPlayer(data: sound.data, fileTypeHint: AVFileTypeMPEGLayer3)
  
                  audioPlayer.play()
  
  
          } catch let error as NSError {
              print("error: \(error.localizedDescription)")
          }
  
  
      }
  </code></pre>
  
  <p>But when I try and invoke the method when I receive a remote notification this doesn't work. I have got alarm to work with my app with remote notification and able to play custom sounds, but that only works when phone is not in silent mode .</p>
  
  <p>There are plenty of apps in app store which is overriding silent mode so I am very sure there is a way to do this but I am not sure how as yet.</p>