I am create html page with HTML5 IMA SDK player and then load this page to WKWebView, all work fine pause, playing content etc, but I want "pause" content when app goes to background for achieve this I did tried used "WKWebView evaluateJavaScript" but this code don't work when app goes to background and did tried this answer (https://stackoverflow.com/questions/53482566/wkwebview-doesnt-run-javascript-when-on-background#:~:text=Javascript%20is%20disabled%20by%20default,WKWebView%20should%20look%20like%20this.&text=Also%20you%20can%20check%20this%20post%20to%20see%20a%20different%20approach) but this don't help me, keyWindow is deprecated and I use another approach:
let keyWindow = UIApplication.shared.connectedScenes .filter({$0.activationState == .foregroundActive}) .map({$0 as? UIWindowScene}) .compactMap({$0}) .first?.windows .filter({$0.isKeyWindow}).first
Also doesn't work.
Which way exist for "evaluateScript" when app goes to background or before app will go to background?
2.1m questions
2.1m answers
63 comments
56.6k users