Skip to main content
MÓDULO NATIVO

Video Recorder

The VideoRecorderUI SDK allows for the capture of a 15-second video selfie using the front-facing camera. Additionally, it validates a token against a verification endpoint before allowing recording to begin. Once finished, it returns the local path of the video on the device so the host app can manage the file (e.g., upload it to a server).
  1. Token Verification: Receives a token and URL, verifies it, and proceeds to video recording if valid.
  2. Video Recording: Requests camera and microphone access to record a 15-second clip with visual indicators.
  3. Returning Results: Invokes an onFinish callback with the result status and the local video file path.
Regresar
IOSSWIFTUIv2.1.0

Compatibilidad y Requisitos

Lenguaje
SwiftUI
OS Min
iOS 13+
Swift
5.5+
IDE
Xcode

Embedding and Signing the Framework

In Xcode, navigate to the “General” tab of the application target, locate the “Frameworks, Libraries and Embedded Content” section, and for the VideoRecorderUI.xcframework framework, select the “Embed & Sign” option from the “Embed” column.

Prerequisites

Camera and microphone permissions: Make sure to add the following permissions to the Info section of the project target or to the Info.plist file:

Info.plist

<key>NSCameraUsageDescription</key>
<string>Please grant permission to use the camera. By Dicio</string>

<key>NSMicrophoneUsageDescription</key>
<string>Please grant microphone permissions for the video recorder by Dicio.</string>
This is essential for iOS to display the access request dialog.

Usage in SwiftUI

1. Import the framework In the file where you intend to trigger video recording, import the framework:

Import

import VideoRecorderUI
2. Initialize and Present the Recording View To start the process, create an instance of the main view, `VideoRecorderVC`, providing it with:

• token: the value obtained from your Dicio service/environment. • urlVerify: the URL where the token will be validated. • onFinish: a callback that receives (isSuccessful, route) upon completion.

Basic example in SwiftUI:

Usage Example

struct VideoRecorderExample: View {
@State private var showRecorder = false
@State private var resultPath: String = ""

var body: some View {
VStack {
Button("Start recording") {
showRecorder = true
}
// Presents the framework in full screen
.fullScreenCover(isPresented: $showRecorder) {
VideoRecorderVC(
token: "YOUR_PROVIDED_TOKEN",
urlVerify: "https://example.service.com",
onFinish: { isSuccessful, route in
if isSuccessful {
print("Video saved at: \\(route)")
resultPath = route
} else {
print("Error or cancellation")
}
}
)
}

Text("Last video path: \\(resultPath)")
.font(.footnote)
}
}
}
**Explanation**

• @State private var showRecorder = false controls whether the framework view is presented as a fullScreenCover.

• When showRecorder is true, VideoRecorderVC is launched.

• The onFinish callback returns the result:

  • isSuccessful = true => Recording was successful, and route will contain the local path.
  • isSuccessful = false => An error occurred or the user cancelled.
  1. Handling the Recording Result The onFinish block executes when the recording ends or if the flow is closed. For example:

Result handling

onFinish: { isSuccessful, route in
if isSuccessful {
// The video is saved in 'route'
print("Video saved at: \\(route)")
// Here you can upload it to your server or use it as needed.
} else {
// There was a problem or it was cancelled
print("Error or cancellation")
}
}
Note: The video file remains in your application's temporary or documents directory (depending on the exact SDK implementation). 
Ensure you manage its lifecycle according to your needs (for example, by copying it to another secure directory or uploading it immediately if you do not wish to store it locally).

Complete Example

Complete Example

import SwiftUI
import VideoRecorderUI

struct VideoRecorder: View {
@State private var showRecorder = false
@State private var resultPath: String = ""

var body: some View {
VStack {
Button("Start recording") {
showRecorder = true
}
.fullScreenCover(isPresented: $showRecorder) {
// Call to the framework
VideoRecorderVC(
token: AppConfig.shared.bearerToken,
urlVerify: AppConfig.shared.laUrlVerifica,
onFinish: { isSuccessful, route in
// Handle the result
if isSuccessful {
print("Video saved at: \\(route)")
resultPath = route
} else {
print("Error or cancellation")
}
}
)
}

Text("Last video path: \\(resultPath)")
.font(.footnote)
}
}
}
  1. The "Start Recording" button opens the full sheet.
  2. Within that sheet, VideoRecorderVC internally performs token verification and, if successful, proceeds with the video recording.
  3. Upon completion (whether successful or resulting in an error), it closes the sheet and invokes your callback.

Additional Considerations

• Error Handling: The SDK internally handles cases involving denied permissions or unauthorized tokens. If the user denies access to the camera or microphone, an alert will appear instructing them to grant the necessary permissions.

• Styling and UI: You can customize the presentation (e.g., using .sheet instead of .fullScreenCover), provided the container is a SwiftUI view.

• Integration into Existing Projects: Ensure your project supports iOS 13+ (or the minimum version you have specified). This SDK is not compatible with earlier versions.

• Versioning: Check the specific version of VideoRecorderUI.xcframework you receive, in case there are updates or API changes.