Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 12.2 - Lockscreen controlos missing

Since I updated to ios 12.2 lockscreen controls stopped to work for me and I can't figure out why. It worked fine in ios 12.1

  1. App has enabled capabilities->Background mores -> Audio
  2. I set UIApplication.shared.beginReceivingRemoteControlEvents()
  3. Then I set

    MPRemoteCommandCenter.shared().playCommand.isEnabled = true                   
    MPRemoteCommandCenter.shared().pauseCommand.isEnabled = true
    MPRemoteCommandCenter.shared().playCommand.addTarget(self, action:#selector(self.playPlayer))
    MPRemoteCommandCenter.shared().pauseCommand.addTarget(self, action: #selector(self.pausePlayer))
    
  4. Then AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) and AVAudioSession.sharedInstance().setActive(true)

I use AVPlayer and AVPlayer item. Locksceen controls never show up on ios 12.2. Any idea what can be causing this issue? Thanks

(I use xcode 10.2 and swift 4.2)

EDIT: I was able to figure out that this happens only when device is online. If I play immediately, lockscreen controls will show up and then disappear in few seconds. If I play later, they will not show up. So it seems they work few seconds after app start and then don't

EDIT 2: Fixed now. Issue was caused by app loading local html file into webview. Completely unrelated to playback but that's it. Solution is not to load webview

like image 658
Martin Vandzura Avatar asked Apr 17 '19 10:04

Martin Vandzura


1 Answers

Issue was caused by app loading local html file into UIWebView. Completely unrelated to playback but that's it. Solution is not to load UIWebView but use WKWebView instead.

Similar issue was discussed here but I found it only because I know already what was causing it.

like image 71
Martin Vandzura Avatar answered Oct 02 '22 15:10

Martin Vandzura