In the session, regarding prompting user for camera or microphone permission, the delegate method shown in the code snippet is the following:
func webView(_ webView: WKWebView, decideMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType) async -> WKPermissionDecision {
return type == .microphone ? .prompt : .deny
}
But, I couldn't find this method in the documentation. Instead, I found this:
func webView(_ webView: WKWebView,
requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void)
Which one is the latest? Thanks!
-
—
LxLGoelzda
-
—
zensen
-
—
zensen
Add a CommentI am currently implementing this method with difficulties.
Its an Cordova Application. The method gets called, I call the
decisionHandlerwithWKPermissionDecisionGrant, there is no Prompt in the Application, but I don't get any audio from the devices mic. I also don't see the orange dot on top which indicates microphone usage.When I change the value of the
decisionHandlertoWKPermissionDecisionPromptit works, however it is back to the annoying behaviour that always asks the user for consent even though he has given it a day (or so) ago.I am working with Xcode 14 RC and iOS/iPadOS 15 RC
Here is the source Code:
- (void)webView:(WKWebView *)webView requestMediaCapturePermissionForOrigin:(WKSecurityOrigin *)origin initiatedByFrame:(WKFrameInfo *)frame type:(WKMediaCaptureType)type decisionHandler:(void (^)(WKPermissionDecision))decisionHandler { decisionHandler(WKPermissionDecisionGrant); }hi could you able to fix that? i am having similar problem in cordova app. would you mind share the filename, and code you added? thank you
this code works, tested with iOS 15
(void)webView:(WKWebView *)webView requestMediaCapturePermissionForOrigin:(WKSecurityOrigin *)origin initiatedByFrame:(WKFrameInfo *)frame type:(WKMediaCaptureType)type decisionHandler:(void (^)(WKPermissionDecision))decisionHandler API_AVAILABLE(ios(15.0)) API_AVAILABLE(ios(15.0)){ decisionHandler(WKPermissionDecisionGrant); }