Social Link
This guide explains how to handle social media link click events in the Firework SDK.
Overview
Quick Start
Setting Up the Listener
import com.firework.sdk.FireworkSdk
import com.firework.videofeed.social.SocialLinkInfo
import com.firework.videofeed.social.SocialPlatform
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set up social link click listener
setupSocialLinkClickListener()
}
private fun setupSocialLinkClickListener() {
FireworkSdk.social.setOnVideoSocialLinkClickListener { info ->
// info contains all click-related information
Log.d("Firework", "Social link clicked: ${info.platform}")
when (info.platform) {
SocialPlatform.TIKTOK -> {
// Custom handling for TikTok links
openTikTokApp(info.username, info.url)
true // Return true to indicate you've handled it
}
SocialPlatform.INSTAGRAM -> {
// Custom handling for Instagram links
openInstagramApp(info.username, info.url)
true
}
SocialPlatform.YOUTUBE -> {
// Custom handling for YouTube links
openYouTubeApp(info.url)
true
}
SocialPlatform.UNKNOWN -> {
// Return false to let SDK open in default browser
false
}
}
}
}
override fun onDestroy() {
// Clean up the listener
FireworkSdk.social.setOnVideoSocialLinkClickListener(null)
super.onDestroy()
}
}Callback Parameters
SocialLinkInfo
Property
Type
Description
SocialPlatform
Value
Description
VideoInfo
Property
Type
Description
VideoType
Value
Description
Return Value
Return Value
Behavior
Best Practices
1. Clean Up Listeners
2. Handle App Not Installed
FAQ
Q: What happens if I don't set a listener?
Q: Can I set listeners in multiple places?
Q: Which thread does the callback run on?
Q: How can I get more video information?
API Reference
Support
Last updated
Was this helpful?