onclarity plugin is a thin Dart layer over the Android and iOS SDKs. The chat opens as a native container over your Flutter UI, so nothing is added to your widget tree and your routes are untouched while it is open.
Requirements: Flutter 3.44 or later, Android API 21 or later, iOS 15 or later.
Get your credentials
A Flutter app ships as two native apps, and Clarity matches a channel per platform, so you need two integration keys. In the cabinet, go to Settings > Mobile SDK, click Add Integration and choose Flutter. Enter both App IDs:
You get one Organization Id and two integration keys, one per platform. The live chat host is
https://live-chat.leap.onclarity.com. These values are identifiers, not secrets, so shipping them in the app is fine.
Install
iOS: raise the deployment target
The iOS SDK needs iOS 15, and Flutter’s app template targets iOS 13, sopod install fails until you raise it. Change it in both places:
pod install in ios/.
Android: Kotlin version
The plugin needs Kotlin 2.0 or later in your Android project. Flutter 3.44’s template already has it. An older project fails withcompiled with an incompatible version of Kotlin; raise the version in android/settings.gradle:
onclarity applies the Kotlin Gradle Plugin. It is harmless, and you have nothing to change.
Initialize
Pass both keys once. The plugin picks the right one for the platform it runs on.Configuration options
Identify the user
ClarityUser also takes lastName, phone and avatar. Changing externalId is an account switch and starts a separate conversation; changing other fields on the same id updates the profile. On logout:
Open the chat
Listen for events
Everything the native SDKs report arrives on one broadcast stream.ClarityEvent is a sealed class, so a switch over it is exhaustive:
await Clarity.refresh() to pull anything missed.
The plugin owns the native listener and fans it out to
Clarity.events. Do not register your own native listener on either platform.Attributes and product events
ArgumentError at your call site.
If your workspace marks contact attributes as required, set them right after
Clarity.init, before the chat first loads. A session missing a required attribute is refused, and show() reports ClarityErrorKind.pageLoadFailed naming the missing keys. Alternatively pass autoPreload: false and call Clarity.preload() once the attributes are set.Push notifications
Clarity’s push routing is FCM-based. Withfirebase_messaging in your app, forward the token and messages from Dart:
AppDelegate forwards it, which Dart cannot do. Add this to ios/Runner/AppDelegate.swift:
POST_NOTIFICATIONS yourself. The SDK never prompts.
Background push delivery is enabled per organization. Ask your Clarity contact about availability.
Huawei and AppGallery builds
If your Android channel was created with My mobile is Huawei, tell the plugin inClarityConfig:
Attachments, voice and dictation
- Camera on iOS: add
NSCameraUsageDescriptiontoios/Runner/Info.plistto enable Take Photo. Photo library and file uploads work without it. - Voice calling and dictation: declare microphone access,
RECORD_AUDIOin the Android manifest andNSMicrophoneUsageDescriptionin the iOS Info.plist. Without it, the chat shows no microphone button.
Customization
The chat’s colours, logos, font and texts come from Settings > Widget in the cabinet, the same settings as the web widget. In code you control the presentation,language and autoFocusInput.
API reference
Troubleshooting
Nothing opens
Nothing opens
Listen to
Clarity.events for ClarityErrorEvent. handshakeRejected means a wrong organization id, integration key or App ID (each channel’s App ID must equal that platform’s identifier), or a Huawei platform mismatch. network means the device cannot reach baseUrl.pod install fails with a platform error
pod install fails with a platform error
Raise the iOS deployment target to 15.0 in
ios/Podfile and in Xcode, as in Install.Kotlin metadata version error on Android
Kotlin metadata version error on Android
Raise your project’s Kotlin Gradle plugin to 2.0 or later, as in Install.
Camera option missing on iOS
Camera option missing on iOS
Add
NSCameraUsageDescription to ios/Runner/Info.plist.