In this example, we will show you how to make basic configurations for the mobile editor. The example is based on the Design Editor, however, it is exactly the same for all the other solutions.
Configuration#
The openEditor function allows for some further basic configuration of the editor.
Editor Settings#
All the basic configuration settings are part of the EditorConfiguration which is required to initialize the editor.
const settings = new EditorSettingsModel({ license: 'YOUR_LICENSE_KEY', // Get your license from https://img.ly/forms/free-trial, pass null for evaluation mode with watermark baseUri: 'YOUR_BASE_URI', userId: 'YOUR_USER_ID'});license- the license to activate the Engine with.
license: 'YOUR_LICENSE_KEY', // Get your license from https://img.ly/forms/free-trial, pass null for evaluation mode with watermarkbaseUri- the base URI used by the engine for built-in assets like emoji and fallback fonts, and by the editor for its default and demo asset sources (stickers, filters, and more). The default value points at the versioned IMG.LY CDNhttps://cdn.img.ly/packages/imgly/cesdk-react-native/<version>/assets. For production use, we recommend downloading the assets, hosting them on your own server, and settingbaseUrito your hosted location.
baseUri: 'YOUR_BASE_URI',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_USER_ID'Source#
source- is used to load in a custom source, e.g. a scene, image or video file.
const source = require('MY_CUSTOM_SOURCE');EditorPreset#
preset- is used to determine which predefined editor variant you want to use - if any.
const preset: EditorPreset = EditorPreset.DESIGN;Metadata#
metadata- can be used to provide any custom{ [key: string]: unknown }to the underlying native plugin which you can use for further custom handling.
const metadata = { MY_KEY: 'MY_VALUE'};Full Code#
import IMGLYEditor, { EditorPreset, EditorSettingsModel,} from '@imgly/editor-react-native';
export const basicEditor = async (): Promise<void> => { const settings = new EditorSettingsModel({ license: 'YOUR_LICENSE_KEY', baseUri: 'YOUR_BASE_URI', userId: 'YOUR_USER_ID', });
const source = require('MY_CUSTOM_SOURCE'); const preset: EditorPreset = EditorPreset.DESIGN; const metadata = { MY_KEY: 'MY_VALUE', };
const result = await IMGLYEditor?.openEditor( settings, source, preset, metadata, );};