Get your credentials
In the cabinet, go to Settings > Mobile SDK, click Add Integration, choose Android and enter your app’sapplicationId as the App ID. The integration dialog shows:
The channel’s App ID must equal your app’s
applicationId; the SDK sends it when the chat session starts and a mismatch is refused. These values are identifiers, not secrets, so shipping them in the APK is fine.
For an AppGallery build, create the channel with My mobile is Huawei checked and pass
platform = ClarityPlatform.HUAWEI in ClarityConfig. Set it from your build flavour, not by probing the device. Chat works on devices without Google services; push notifications do not, because push is FCM-only.Install
The SDK is on Maven Central, so no extra repository is needed.Initialize
CallClarity.init once, in Application.onCreate:
Configuration options
Identify the user
After your user logs in, and before the first open:ClarityUser also takes phone, avatar and jwt.
- Calling
identifywith a differentexternalIdis a logout plus login: the previous user’s session is wiped, so conversations never leak between users. - Calling it again with the same
externalIdand new profile fields updates the profile and keeps the conversation. - On logout, call
Clarity.resetSession().
Verify the user (signed identity)
AnexternalId alone is a claim the app makes about itself. To have Clarity trust it, your backend signs a short-lived JWT for the user with the channel’s identity secret, and the app passes it as jwt:
- When the token expires, fetch a new one and call
identifyagain with the sameexternalId. The conversation is kept. - A refused token makes
show()reportPAGE_LOAD_FAILEDwith code401, and the message names the reason.
Open the chat
Badge your Help button
EveryClarityListener method is optional:
Clarity.unreadCount, Clarity.isWidgetVisible and Clarity.currentTicketStatus directly. unreadCount is a flag: 1 while unseen replies exist, else 0.
Delivery while the chat is closed is best effort. When freshness matters, for example when the app returns to the foreground, call Clarity.refresh(). Missed replies and status changes arrive through the same listener.
Attributes and product events
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 PAGE_LOAD_FAILED naming the missing keys. With autoPreload = true the first load starts about 1.5 seconds after init; alternatively set autoPreload = false and call Clarity.preload() once the attributes are set.Push notifications
While your app is running, replies that arrive with the chat closed already show a system notification; a tap reopens the chat. On Android 13 and later, requestPOST_NOTIFICATIONS yourself. The SDK never prompts.
For replies while your app is killed or long in the background, forward your Firebase token and let Clarity handle its own pushes:
Clarity.setDeviceToken(...) once at app start with the current token. Clarity.isClarityPush(data) tells you whether a message is Clarity’s without handling it.
Background push delivery is enabled per organization. Ask your Clarity contact about availability.
Attachments, voice and dictation
Customers can attach images and PDFs through the system file picker. No permissions or manifest entries are needed. If your organization uses voice calling or dictation in the chat, declare the microphone permission in your manifest:Customization
The chat’s colours, logos, font and texts come from Settings > Widget in the cabinet, the same settings as the web widget. Per-app switches such as voice calling, dictation and the Inbox tab are in the Android integration’s dialog. In code you control the presentation (presentationMode, sheetHeightFraction), language and autoFocusInput.
API reference
Troubleshooting
Every failure arrives inonError as a ClarityError with a kind:
Nothing appears on show()
Nothing appears on show()
Check
onError. HANDSHAKE_REJECTED means the organization id, integration key or App ID is wrong (the App ID must equal your applicationId), or the channel is Huawei and platform is not ClarityPlatform.HUAWEI, or the reverse. NETWORK means the device cannot reach baseUrl: check that Chrome on the same device opens it. In debug builds, a diagnostic screen names the reason.Replies while the chat is closed do not notify
Replies while the chat is closed do not notify
On Android 13 and later, request
POST_NOTIFICATIONS. The SDK never prompts for it.Voice calls fail with "Could not start voice chat"
Voice calls fail with "Could not start voice chat"
Update to 1.6.1, which declares
MODIFY_AUDIO_SETTINGS. On an older version, add <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> to your manifest.The chat does not open after adding jwt
The chat does not open after adding jwt
show() reports PAGE_LOAD_FAILED with code 401. The message says whether the token was invalid, expired, missing or malformed. Check that your backend signs with the channel’s current identity secret and sets a valid exp.