The solution is to set the uiDelegate on your WKWebView. The unreleased version of WKWebView (included in iOS 15 perhaps?) includes a UI delegate callback that lets you grant this permission without UI being presented. See:
https://github.com/WebKit/WebKit/blob/7891d2662792303261d10944c9ccf3b9b9d7c46b/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegate.h#L154
Topic:
Safari & Web
SubTopic:
General
Tags: