Skip to content

Commit

Permalink
Merge pull request #818 from WalletConnect/feature/w3i-camera
Browse files Browse the repository at this point in the history
[W3I] Access to camera
  • Loading branch information
flypaper0 authored Apr 25, 2023
2 parents 34390b5 + ef2fed7 commit b8f6cdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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)
}
}

0 comments on commit b8f6cdc

Please sign in to comment.