SFSafariViewController permission prompt not coming up

Context:

I want to use SFSafariViewController to load a webpage which uses webRTC for a video based call. So the webpage internally uses navigator.mediaDevices.getUserMedia API to get the camera and microphone permissions.

Issue:

Now the issue is whenever the camera and microphone permissions are set to Ask which is the default permission, there is no permission prompt coming up and the permissions are automatically denied. Also, this issue is very inconsistent meaning sometimes the permission prompt is shown but sometimes its not shown.

When the permissions for the particular webpage is set to Allow everything works fine.

Code:

#import <React/RCTLog.h>

@implementation SafariWebViewModule

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(customWebView:(NSString *)url) {
    SFSafariViewController *safariViewController = [[SFSafariViewController alloc]
        initWithURL:[NSURL URLWithString:url]
        entersReaderIfAvailable:YES];

      safariViewController.delegate = self;

      dispatch_async(dispatch_get_main_queue(), ^{
        UIViewController *rootViewController = [[
          [UIApplication sharedApplication] keyWindow] rootViewController];

        [rootViewController presentViewController:safariViewController animated:YES completion: nil];
      });

}

-(void) safariViewControllerDidFinish:(nonnull SFSafariViewController *)controller {
  UIViewController *rootViewController = [
    [[UIApplication sharedApplication] keyWindow] rootViewController];

  [rootViewController dismissViewControllerAnimated:YES completion:nil];
}


@end

Help:

If anyone has any idea about how to fix this issue please help, thanks in advance.

While this isn't an answer (and I'm not an expert here), I'm wondering what your settings are under Settings > Safari > Camera | Microphone (under Settings for Websites)? Are they set to Ask, Deny, or Allow on all websites?

Can you also confirm that you're loading an HTTPS URL (not, for example, an HTTP URL that (sometimes?) redirects to HTTPS?

Finally, can you confirm that the page being loaded is a top-level page, not one loaded in (for example) an iframe?

Website settings for Camera and Microphone are set to Ask. The URL is https and not http. Yes, the page is a top-level page and not loaded in iframe.

I interesting thing is if I load the same page in reddit app (which also uses safari webview to open external links) everything is working properly and I can see the permission prompt everytime.

Also, this gives me a hunch that I am using ios v13 and since webRTC support was introduced in ios v13 only there might be any bugs which they would have fixed in later versions and reddit app might be using the latest version. But this is a hypothesis and I don't have any data points to back it up.

SFSafariViewController permission prompt not coming up
 
 
Q