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
capabilities->Background mores -> Audio
UIApplication.shared.beginReceivingRemoteControlEvents()
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))
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With