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.