In this example, we will show you how to configure the camera.
License#
All the basic configuration settings are part of the EngineSettings
which are required to initialize the camera.
let settings = EngineSettings(license: secrets.licenseKey, userID: "<your unique user id>")
license
– the license to activate the Engine with.
let settings = EngineSettings(license: secrets.licenseKey,
userID
– an optional unique ID tied to your application’s user. This helps us accurately calculate monthly active users (MAU). Especially useful when one person uses the app on multiple devices with a sign-in feature, ensuring they’re counted once. Providing this aids in better data accuracy. The default value isnil
.
userID: "<your unique user id>")
Configuration#
You can optionally pass a CameraConfiguration
struct to the Camera
initializer.
let config = CameraConfiguration( recordingColor: .blue, highlightColor: .yellow, maxTotalDuration: 30, allowModeSwitching: true)
recordingColor
– the color of the record button.
recordingColor: .blue,
highlightColor
– the highlight color of the delete and confirm buttons.
highlightColor: .yellow,
maxTotalDuration
– the total duration that the camera is allowed to record.
maxTotalDuration: 30,
allowModeSwitching
– Set tofalse
to lock the camera into its initial mode.
allowModeSwitching: true
Mode#
You can optionally configure the initial mode of the camera.
Available Modes#
.standard
: the regular camera..dualCamera(layoutMode)
: records with both front and back camera at the same time.layoutMode
determines the layout of the two cameras. Available options are.horizontal
and.vertical
.
.reaction(layoutMode, URL, positionsSwapped)
: records with the camera while playing back a video.layoutMode
determines the layout of the two cameras. Available options are.horizontal
and.vertical
.URL
the URL to video to record a reaction to.positionsSwapped
a boolean indicating if the video and camera feed should swap positions. By default, the video being reacted to is on the top/left (depending onlayoutMode
).
mode: .standard
Full Code#
Here’s the full code:
import IMGLYCameraimport SwiftUI
struct ConfiguredCameraSolution: View { let settings = EngineSettings(license: secrets.licenseKey, userID: "<your unique user id>")
@State private var isPresented = false
var body: some View { Button("Open the Camera") { isPresented = true } .fullScreenCover(isPresented: $isPresented) { let config = CameraConfiguration( recordingColor: .blue, highlightColor: .yellow, maxTotalDuration: 30, allowModeSwitching: true )
Camera( settings, config: config, mode: .standard ) { result in switch result { case let .success(cameraResult): print(cameraResult) case let .failure(error): print(error.localizedDescription) isPresented = false } } } }}
Localization#
The CE.SDK camera currently supports English and German languages on iOS, however it provides convenient API to replace the values of existing localization keys or add support for more languages.
All the camera keys are located here and they all follow strict naming convention to make locating keys simple and self-explanatory.
For instance, the timer off button can be found via ly_img_camera_timer_option_off
key, or the title in the alert dialog of deleting last recording can be found via ly_img_camera_dialog_delete_last_recording_title
key.
Replacing existing keys#
In order to replace any of the existing camera keys, find the key of the desired text, add the key to Localizable.xcstrings
file of your app and replace with the desired value or copy the IMGLYCamera.xcstrings
file to your app and edit it. Keys defined in Localizable.xcstrings
take precedence over the ones defined in IMGLYCamera.xcstrings
.
Supporting new languages#
In order to add support for a language that is not supported by the CE.SDK camera add a new language to your Localizable.xcstrings
or IMGLYCamera.xcstrings
file and replace the values with desired translations.