Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Livestream Chat

The Firework SDK provides chat management APIs for livestream content. This guide covers username configuration, chat message handling, and related features.

Overview

Livestream chat allows viewers to interact with hosts and other viewers during live. The SDK provides methods to:

  • Update and retrieve user display names

  • Configure username visibility and editability

All chat management APIs are accessed through FireworkSdk.livestream.

Username Management

updateUsername()

Updates the user's display name in livestream chat.

Signature:

fun updateUsername(username: String?)

Parameters:

  • username - The new username to set (null to clear)

Description: Sets or updates the display name shown in livestream chat. This name will be visible to other viewers when the user sends chat messages.

Example:

With Success/Failure Handling:

To monitor the result of username updates, use setOnUpdateUsernameListener():

Use Cases:

  • Set username when user logs in

  • Allow users to change their display name

  • Personalize chat experience

  • Sync with your app's user profile

Important Notes:

  • Username changes are applied to all active livestream sessions

  • Previous chat messages will still show the old username

  • Username validation (length, characters) is handled by the SDK

  • Set the update listener before calling updateUsername() to receive callbacks


getUsername()

Retrieves the current username.

Signature:

Returns:

  • String? - Current username, or null if not set

Description: Returns the currently configured username for livestream chat. This is the name that will be displayed when the user sends messages.

Example:


updateUsernameConfiguration()

Configures username display and editing behavior.

Signature:

Parameters:

  • config - Configuration object controlling username behavior

Description: Updates the configuration for how usernames are displayed and whether users can edit them. This affects the chat UI behavior.

UsernameConfiguration Data Class:

Properties:

isEditable

  • Type: Boolean

  • Default: true

  • Description: Controls whether users can edit their username

  • When true: Users can tap their username to change it

  • When false: Username is locked and cannot be changed

isHidden

  • Type: Boolean

  • Default: false

  • Description: Controls username visibility in chat input

  • When true: The "Chat as XXX" hint is hidden from the chat input view

  • When false: Username is displayed in the chat input hint

API Summary

Method
Description
Returns

updateUsername()

Update user display name

Unit

getUsername()

Get current username

String?

updateUsernameConfiguration()

Configure username behavior

Unit

Data Classes

Class
Properties
Description

UsernameConfiguration

isEditable: Boolean isHidden: Boolean

Username display configuration

ChatMessage

username: String messageId: String text: String

Chat message data

Multiple pinned messages

Since 6.35.1, the V2 chat experience supports multiple pinned messages in livestream, replay, and rebroadcast content. The area displays one message at a time; previous/next controls cycle through the messages and show the current position and total count. With one message, the switching controls are hidden; with none, the pinned-message area is hidden.

Regular messages and coupon messages can coexist. Coupon messages provide a copy action and confirmation. Pinned messages follow the list configured for the broadcast. The legacy V1 experience retains single-message compatibility.

Use ChatOption.pinMessageStyle to customize V2 pinned text and background colors. No additional listener registration is required to display pinned messages.

Comment giveaways

Since 6.37.0, the V2 livestream player supports comment giveaways in live broadcasts and replays. In a comment giveaway, viewers enter by commenting a keyword in chat. When the host ends the giveaway, each viewer privately sees whether they won. Hosts create comment giveaways in Firework CMS; your app needs no extra code to display them.

What viewers see

  1. While a giveaway is running, a Comment Giveaway pill appears below the player's title bar.

  2. Tapping the pill opens a sheet with the host's prompt and the keyword to comment.

  3. The viewer enters by sending the keyword as a chat message.

  4. When the host ends the giveaway, the sheet opens automatically and shows that viewer's result:

    • Winner: a congratulations message and a Claim Your Reward button that opens the reward link set by the host. The pill stays visible for the rest of the viewing session, so the viewer can return to the link.

    • Other participants: a "Better luck next time" message. The pill is removed.

If several giveaways run at the same time, each one has its own pill, and running giveaways are listed first.

In a replay, the giveaway appears at the point in the recording where it ran. Results come from the live broadcast: a viewer sees a winning result only if they won during the live broadcast. Replays show comment giveaways only when the livestream's replay interaction setting is turned on.

Each reward link belongs to one winner. If a viewer pastes their reward link into chat, the message is shown only to them and is not sent to other viewers.

How your SDK callbacks apply

Comment giveaways need no new API. Check how these existing callbacks interact with them:

  • Chat interception: viewers enter by sending a chat message. If your onUserSendMessage() returns true for a message, the message is not sent to chat and does not count as an entry. Return false for messages that should reach the livestream, or the viewer will not be entered.

  • Interaction listener: comment giveaways are not reported to setOnInteractionListener(). onUserJoinGiveaway() is called only for standard giveaways.

  • Link handling: the Claim Your Reward button opens the reward link with a standard Android ACTION_VIEW intent, usually in the viewer's browser. It does not call setOnLinkClicked().

Last updated

Was this helpful?