Please jump to the right section for your issue
- I am on Safari and iOS > 13
- I am on Safari and iOS < 13
- I am on a Progressive Web App (PWA)
- I am on a WKWebView
- I am on other browsers
On Safari with iOS > 13
You need to open your website and then tap the "AA" icon in the bottom-left. Then tap "Website Settings" which will enable you to set camera permissions to "Allow" instead of "Ask".
This will set the camera permissions to allow by default, so it won't ask for permissions again.
On Safari with iOS < 13
iOS has a somewhat heavy-handed implementation of user permissions for camera access in the Safari browser. The permissions are not persistent and are re-requested with every page load.
If you have a single-page app, you should expect to grant camera access once per application load.
However, if you're loading the page each time you need to scan, you will see the camera permission dialog. Whenever possible, we recommend implementing your workflow without reloading the page.
Unfortunately, PWAs are revoking camera access privileges whenever the hash changes. If you would like to add your voice for this issue to be solved, you can post it on this ticket.
With the release of iOS 15, Apple introduced the ability to request media capture permission directly from the
WKWebView. This provides more control over how and when the user is prompted for camera and microphone access.
To implement this feature, we will first need to implement the
WKUIDelegate method To your
ViewController. This method is called when the
WKWebView encounters a request for camera or microphone access from a website.
Here’s how it looks:
@available(iOS 15, *)
_ webView: WKWebView,
requestMediaCapturePermissionFor origin: WKSecurityOrigin,
initiatedByFrame frame: WKFrameInfo,
decisionHandler: @escaping (WKPermissionDecision) -> Void
You also need to add the
WKUIDelegate to your
ViewController and set
webView.uiDelegate = self and your done.
No more permission request from the WebView.
A good thing to note though is that this will allow permissions from all sites, you should probably limit it to use only the url’s you want.
On other browsers
Unfortunately, saving camera access permission is currently not supported by Apple on other browsers than Safari.