Livestream Callbacks
The Firework SDK provides comprehensive callback interfaces for handling user interactions during livestreams. This guide covers all available callbacks and their usage.
Overview
Livestream callbacks allow you to respond to user actions during live broadcasts, replays, and trailers. All callbacks are accessed through FireworkSdk.livestream and provide video context information via the VideoInfo parameter.
Link Click Listener
setOnLinkClicked()
Handles clicks on links within livestream content (e.g., product links, external URLs, promotional links).
Signature:
fun setOnLinkClicked(listener: OnLinkClickListener?)Listener Interface:
fun interface OnLinkClickListener {
fun onLinkClick(title: String?, url: String?, videoInfo: VideoInfo)
}Parameters:
title- Link title or description (can be null)url- The URL to open (can be null)videoInfo- Context information about the current video
Example:
Use Cases:
Open product pages when users tap product links
Handle deep links to specific app screens
Track link click analytics
Open external promotional content
Remove Listener:
Interaction Listener
setOnInteractionListener()
Handles various user interactions during livestreams including questions, polls, giveaways, chat messages, and likes.
Signature:
Listener Interface:
onUserSubmitAnswerToQuestion()
Called when a user submits an answer to a question during a livestream.
Parameters:
videoInfo- Context information about the current videoquestion- Question interaction details
Question Interaction:
Returns: Boolean
true- Interaction handled by your appfalse- Let SDK handle the interaction (default behavior)
Example:
onUserSelectOptionForPoll()
Called when a user selects an option in a poll during a livestream.
Parameters:
videoInfo- Context information about the current videopoll- Poll interaction details
Poll Interaction:
Returns: Boolean
true- Interaction handled by your appfalse- Let SDK handle the interaction (default behavior)
Example:
onUserJoinGiveaway()
Called when a user joins a giveaway during a livestream.
Parameters:
videoInfo- Context information about the current videogiveaway- Giveaway interaction details
Giveaway Interaction:
Returns: Boolean
true- Interaction handled by your appfalse- Let SDK handle the interaction (default behavior)
Example:
onUserSendMessage()
Called when a user sends a chat message during a livestream.
Parameters:
videoInfo- Context information about the current videomessage- Chat message details
Chat Message:
Returns: Boolean
true- Message handled by your app (message will not be sent to chat)false- Let SDK handle the message (message will be sent)
Example:
onUserSendLike()
Called when a user sends a like/heart during a livestream.
Parameters:
videoInfo- Context information about the current video
Returns: Boolean
true- Like handled by your app (like will not be sent)false- Let SDK handle the like (like will be sent)
Example:
Complete Interaction Listener Example:
Remove Listener:
Giveaway Terms and Conditions Listener
setOnGiveawayTermsAndConditionsClickListener()
Handles clicks on giveaway terms and conditions links.
Signature:
Listener Interface:
Parameters:
type- Widget type where the click occurredtitle- Title of the terms and conditionsurl- URL to the terms and conditions page (can be null)videoInfo- Context information about the current video
Example:
Use Cases:
Open terms and conditions in a WebView
Display terms in a custom dialog
Track T&C view analytics
Enforce user agreement before giveaway entry
Remove Listener:
Username Update Listener
setOnUpdateUsernameListener()
Monitors username update results (success or failure).
Signature:
Listener Interface:
onUsernameUpdateSuccessfully()
Called when username is updated successfully.
Parameters:
videoInfo- Context information about the current videousername- The new username that was set
Example:
onUsernameUpdateFailed()
Called when username update fails.
Parameters:
videoInfo- Context information about the current videousername- The username that failed to update (can be null)error- Error message describing why the update failed (can be null)
Example:
Complete Example:
Remove Listener:
VideoInfo Context
All callbacks provide a VideoInfo object containing context about the current video:
Common Uses:
Track analytics with video context
Implement video-specific logic
Display video information in custom UI
Link interactions to specific content
Best Practices
Return Values
Return
truewhen you handle the interaction completely and want to prevent default SDK behaviorReturn
falsewhen you want SDK to handle the interaction after your custom logic
Performance
Keep callback implementations lightweight
Avoid blocking operations
Use coroutines for async work
Cache frequently accessed data
Related Documentation
Livestream Overview - Complete livestream integration guide
Livestream Chat - Chat management and username configuration
FireworkSdk API Reference - Complete API documentation
Getting Started - SDK initialization
API Summary
setOnLinkClicked()
Handle link clicks
void
setOnInteractionListener()
Handle all user interactions
void
onUserSubmitAnswerToQuestion()
Handle question submissions
Boolean
onUserSelectOptionForPoll()
Handle poll votes
Boolean
onUserJoinGiveaway()
Handle giveaway entries
Boolean
onUserSendMessage()
Handle chat messages
Boolean
onUserSendLike()
Handle like actions
Boolean
setOnGiveawayTermsAndConditionsClickListener()
Handle T&C clicks
void
setOnUpdateUsernameListener()
Monitor username updates
void
Last updated
Was this helpful?