【发布时间】:2020-11-29 19:36:50
【问题描述】:
我在 SwiftUI 视图内的 WKWebView 中播放 youtube 视频(嵌入 url)时遇到问题。
这是我的 SwiftUI WebView 代码
import SwiftUI
import UIKit
import WebKit
struct WebView: UIViewRepresentable {
let url: String
func makeUIView(context: Context) -> WKWebView {
let webViewConfig = WKWebViewConfiguration()
webViewConfig.mediaTypesRequiringUserActionForPlayback = .all
webViewConfig.allowsInlineMediaPlayback = true
return WKWebView(frame: .zero, configuration: webViewConfig)
}
func updateUIView(_ view: WKWebView, context: UIViewRepresentableContext<WebView>) {
view.load(request)
}
}
我像Webview(url: "YOUTUBEEMBEDVIDEOURLHERE")这样使用这个WebView,重点如下,我第一次进入屏幕并点击播放按钮,url呈现一切都很顺利,此时,我返回(使用NavigationView ) 并再次进入同一屏幕并再次单击播放视频,然后我就崩溃了。
崩溃信息
Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=3 "Required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Required target entitlement is missing}>
[ProcessSuspension] 0x1479e9930 - ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 60999, error: Error Domain=RBSAssertionErrorDomain Code=3 "Required target entitlement is missing" UserInfo={RBSAssertionAttribute=<RBSDomainAttribute| domain:"com.apple.webkit" name:"Background" sourceEnvironment:"(null)">, NSLocalizedFailureReason=Required target entitlement is missing}
Error acquiring assertion: <Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}>
ProcessAssertion: Failed to acquire RBS Background assertion 'WebProcess Background Assertion' for process with PID 60999, error: Error Domain=RBSAssertionErrorDomain Code=2 "Specified target process does not exist" UserInfo={NSLocalizedFailureReason=Specified target process does not exist}
_userSettingsForUser : (null)
_WebFilterIsActive returning: NO
我尝试启用后台权限,但没有成功
【问题讨论】:
-
我在这里遇到了完全相同的问题 .. 使用带电容器的 Ionic 5 .. 仅适用于 iOS 14。这与 https://github.com/ionic-team/ionic-framework/issues/21613 有关。你找到解决办法了吗?
-
不,我没有,我终于用另一个库来播放视频,它工作,尝试找到一个替代库来做,我只能说=(,保重!
-
我只有在 iOS 上有同样的问题。 14、你有没有找到解决办法?
标签: ios background swiftui wkwebview