If you want to use VideoAsk in your native mobile application, here's what you need to know.
Videoasks can be used in native mobile apps by loading them in WebViews. Add the parameters and settings described below to your native app for an optimal experience with VideoAsk video and audio recordings.
iOS instructions
Use a WKWebView
with the following settings:
- SetĀ
allowsInlineMediaPlayback
Ā totrue
: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1614793-allowsinlinemediaplayback - SetĀ
mediaTypesRequiringUserActionForPlayback
Ā toWKAudiovisualMediaTypeNone
: https://developer.apple.com/documentation/webkit/wkwebviewconfiguration/1851524-mediatypesrequiringuseractionfor -
Set a
uiDelegate
for theWKWebView
like this:wkWebView.uiDelegate = self
Ā
Then, add the following code so the app inherits the parent app's camera and microphone permissions:extension YourViewController: WKUIDelegate {
Ā @available(iOS 15.0, *)
Ā func webView(
Ā Ā Ā _ webView: WKWebView,
Ā Ā Ā decideMediaCapturePermissionsFor origin: WKSecurityOrigin,
Ā Ā Ā initiatedBy frame: WKFrameInfo,
Ā Ā Ā type: WKMediaCaptureType
Ā ) async -> WKPermissionDecision {
Ā Ā Ā return .grant
Ā }
}Ā
The record button is hidden when opening a videoask in a WebView of my iOS app, so it makes it tricky for respondents to answer. How can I solve this?
This can be fixed by adding a little extra code to your embed code:
let configuration = WKWebViewConfiguration() configuration.allowsInlineMediaPlayback
Ā = true
webView = WKWebView.init(frame: .zero,
Ā configuration: configuration)
Android instructions
Use aĀ WebView
Ā with the following settings:
- Make sure that your app already has access to
RECORD_AUDIO
,CAMERA
Ā andĀWRITE_EXTERNAL_STORAGE
, and request permissions if it doesn't - SetĀ
webview.settings.javaScriptEnabled
Ā totrue
- You can overrideĀ
webViewClient
'sĀshouldOverrideUrlLoading
Ā to returnĀtrue
- You should overrideĀ
webChromeClient
'sĀonPermissionRequest
Ā to automatically grant permissions
You can find a complete exampleĀ here.
To detect that a videoask was completed, use theĀ Redirect to URL feature to send users to a URL on completion, and listen to the URL change event.