Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[W3I] Access to camera #818

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Example/ExampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Showcase/Other/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "Allow the app to scan for QR codes";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "If you want to use the microphone, you have to give permission.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
Expand Down Expand Up @@ -2508,6 +2509,7 @@
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Showcase/Other/Info.plist;
INFOPLIST_KEY_NSCameraUsageDescription = "Allow the app to scan for QR codes";
INFOPLIST_KEY_NSMicrophoneUsageDescription = "If you want to use the microphone, you have to give permission.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
Expand Down
2 changes: 2 additions & 0 deletions Sources/Web3Inbox/WebView/WebViewFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ final class WebViewFactory {

func create() -> WKWebView {
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = true
configuration.userContentController.add(
webviewSubscriber,
name: WebViewRequestSubscriber.name
)
let webview = WKWebView(frame: .zero, configuration: configuration)
let request = URLRequest(url: URL(string: host)!)
webview.load(request)
webview.uiDelegate = webviewSubscriber
return webview
}
}
8 changes: 8 additions & 0 deletions Sources/Web3Inbox/WebView/WebViewRequestSubscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ final class WebViewRequestSubscriber: NSObject, WKScriptMessageHandler {
}
}
}

extension WebViewRequestSubscriber: WKUIDelegate {

@available(iOS 15.0, *)
func webView(_ webView: WKWebView, requestMediaCapturePermissionFor origin: WKSecurityOrigin, initiatedByFrame frame: WKFrameInfo, type: WKMediaCaptureType, decisionHandler: @escaping (WKPermissionDecision) -> Void) {
decisionHandler(.grant)
}
}