简体   繁体   English

iOS 12.2 - 缺少锁屏控制

[英]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. 自从我更新到ios 12.2锁屏控件停止为我工作,我无法弄清楚为什么。 It worked fine in ios 12.1 它在ios 12.1中运行良好

  1. App has enabled capabilities->Background mores -> Audio 应用已启用capabilities->Background mores -> Audio
  2. I set UIApplication.shared.beginReceivingRemoteControlEvents() 我设置了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) 然后是AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) and AVAudioSession.sharedInstance().setActive(true)

I use AVPlayer and AVPlayer item. 我使用AVPlayerAVPlayer项目。 Locksceen controls never show up on ios 12.2. Locksceen控件永远不会出现在ios 12.2上。 Any idea what can be causing this issue? 知道是什么导致了这个问题吗? Thanks 谢谢

(I use xcode 10.2 and swift 4.2) (我使用xcode 10.2和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. 编辑2:现在修复。 Issue was caused by app loading local html file into webview. 问题是由app将本地html文件加载到webview中引起的。 Completely unrelated to playback but that's it. 与播放完全无关,但就是这样。 Solution is not to load webview 解决方法是不加载webview

Issue was caused by app loading local html file into UIWebView. 问题是由app将本地html文件加载到UIWebView引起的。 Completely unrelated to playback but that's it. 与播放完全无关,但就是这样。 Solution is not to load UIWebView but use WKWebView instead. 解决方案不是加载UIWebView而是使用WKWebView。

Similar issue was discussed here but I found it only because I know already what was causing it. 这里讨论了类似的问题,但我发现它只是因为我已经知道是什么导致了它。

I agree with vandzi's answer. 我同意vandzi的回答。 We investigated it further and figured out in our case it was the use of UIWebView in Google Mobile Ads framework for showing Ads. 我们对此进行了进一步调查,并在我们的案例中指出,在Google移动广告框架中使用UIWebView来展示广告。 Whenever the Ads HTML content has some audio component associated with it, the Audio session loses focus. 每当广告HTML内容与其关联的某些音频组件时,音频会话就会失去焦点。 PS This was happening only on iOS 12.2 and above, as stated above. PS如上所述,这仅在iOS 12.2及更高版本上发生。 (we verified this in the same test environment for different iOS versions.) (我们在不同iOS版本的相同测试环境中验证了这一点。)

Update: Now Apple has started sending warning messages for deprecated use of UIWebView while deploying the App to app store. 更新:现在Apple已经开始发送警告消息,以便在将App部署到应用商店时弃用UIWebView。

MESSAGE: " ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs". 消息:“ITMS-90809:不推荐使用的API使用 - Apple将停止接受使用UIWebView API的应用程序的提交”。 Link: https://forums.developer.apple.com/thread/122114 链接: https//forums.developer.apple.com/thread/122114

Sharing this as some of us might not be using UIWebview directly and via some third party. 分享这个,因为我们中的一些人可能没有直接使用UIWebview并通过某些第三方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM