iOS Configuration
LovinaChatConfig
The LovinaChatConfig struct holds all configuration options for the chat widget.
let config = LovinaChatConfig(
websiteToken: "your-website-token",
baseUrl: "https://chat.ailovina.com",
locale: "en",
colorScheme: "auto",
user: nil,
displayMode: "fullscreen",
theme: nil,
branding: nil,
texts: nil,
features: nil
)
Fields
| Parameter | Type | Default | Required | Description |
|---|---|---|---|---|
websiteToken | String | -- | Yes | Your Lovina website token for this agent. Obtained from the Lovina dashboard -- each agent has its own token. |
baseUrl | String | -- | Yes | Base URL of your Lovina instance (e.g., https://chat.ailovina.com). |
locale | String | "id" | No | Widget locale code. Supported values include "id", "en", "ar". |
colorScheme | String | "auto" | No | Dark mode preference for the widget. Accepts "light", "dark", or "auto" (follows system theme). |
user | LovinaChatUser? | nil | No | Pre-identified user to associate with the conversation. See below. |
identity | LovinaChatIdentity? | nil | No | Signed identity proof (HMAC) verifying the session's user. See Identity Verification. |
theme | LovinaThemeConfig? | nil | No | Theme color and layout overrides. Only primaryColor is required in practice -- see Theming. Colors are hex Strings, not UIColor. |
branding | LovinaBrandingConfig? | nil | No | White-label branding overrides (logo, brand name, "powered by" footer). |
texts | [String: Any]? | nil | No | UI string overrides, keyed by translation key. |
features | LovinaFeatureFlags? | nil | No | Feature-flag overrides. See File Uploads. |
displayMode | String | "fullscreen" | No | Widget display mode. Accepts "popup", "sidebar", or "fullscreen". |
hideKeyboardAccessoryBar | Bool | true | No | Suppress WebKit's keyboard form-assistant bar while the chat widget's WebView is focused. Scoped to this widget's WKWebView instance only. |
Theming
Only LovinaThemeConfig.primaryColor is required in practice -- every other color is auto-generated by the widget to meet WCAG AA contrast. Colors are hex strings (e.g. "#6366F1"), not UIColor:
LovinaChatConfig(
websiteToken: "your-website-token",
baseUrl: "https://chat.ailovina.com",
theme: LovinaThemeConfig(
primaryColor: "#6366F1",
fontFamily: "Inter, sans-serif",
bubbleRadius: 16
),
branding: LovinaBrandingConfig(
brandName: "Acme Support",
poweredBy: false
)
)
Identity Verification (optional)
identity proves a session belongs to a specific user with a server-signed HMAC:
let config = LovinaChatConfig(
websiteToken: "YOUR_TOKEN",
baseUrl: "https://chat.ailovina.com",
identity: LovinaChatIdentity(
userId: "user-123",
exp: 1735689600,
sigHash: "server-computed-hmac-hash"
)
)
| Option | Type | Description |
|---|---|---|
mode | String | Identity mode. Always "user" (the default). |
userId | String | The same user ID you pass as identifier in LovinaChatUser. |
exp | Int | Unix timestamp (seconds) after which sigHash expires. |
sigHash | String | HMAC signature computed on your server -- never in the app. |
See the User Identification guide for how to compute sigHash.
LovinaChatUser
The LovinaChatUser struct represents a pre-identified user.
| Parameter | Type | Required | Description |
|---|---|---|---|
identifier | String | Yes | Unique user ID in your system. |
name | String? | No | Display name. |
email | String? | No | Email address. |
phoneNumber | String? | No | Phone number (E.164 format recommended). |
customAttributes | [String: Any]? | No | Arbitrary key-value metadata attached to the contact. |
File Uploads
File uploads are disabled by default. Enable the composer's attach button with:
LovinaChatConfig(
websiteToken: "your-website-token",
baseUrl: "https://chat.ailovina.com",
features: LovinaFeatureFlags(enableFileUpload: true)
)
The chat widget's file picker lets users attach photos and videos, including capturing them
directly with the camera. To support this, your app's Info.plist must declare both:
NSCameraUsageDescriptionNSMicrophoneUsageDescription
If either key is missing, the camera capture option still appears in the file picker -- but tapping it terminates your app. There is no degraded fallback; the app crashes immediately. This is default WKWebView behavior that the SDK doesn't control: iOS decides whether to offer the camera option based on the file types your app accepts, before any app code runs. Declaring both keys above is the only way to prevent the crash while keeping full attachment support.
<key>NSCameraUsageDescription</key>
<string>Used to take photos and videos to attach to chat messages.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Used to record audio for videos attached to chat messages.</string>
If you forget to add these keys, the SDK logs a console warning naming the missing key(s) the
first time you call configure(_:), so you can catch the misconfiguration during development
instead of discovering it from a crash report.
Example: Full Configuration
import LovinaChatSDK
let config = LovinaChatConfig(
websiteToken: "lvk_live_xxxx",
baseUrl: "https://chat.ailovina.com",
locale: "en",
colorScheme: "dark",
identity: LovinaChatIdentity(
userId: "user-12345",
exp: 1735689600,
sigHash: "server-computed-hmac-hash"
),
user: LovinaChatUser(
identifier: "user-12345",
name: "Jane Doe",
email: "jane@example.com",
phoneNumber: "+6281234567890",
customAttributes: [
"plan": "premium",
"signup_date": "2025-01-15"
]
),
displayMode: "fullscreen",
theme: LovinaThemeConfig(
primaryColor: "#6366F1"
),
branding: LovinaBrandingConfig(
brandName: "Acme Support"
)
)