Customize click behaviors (iOS)
The SDK provides behavior delegate methods to customize click behaviors, including those for the video CTA button, product cards, and shopping CTA button.
Customize video overlay CTA button click behavior
Set
FireworkVideoCTADelegatedelegate:
FireworkVideoSDK.ctaDelegate = <FireworkVideoCTADelegate delegate>2. Implement handleCustomCTAClick(_:url:for:):
func handleCustomCTAClick(
_ viewController: PlayerViewController,
url: URL,
for video: VideoDetails
) -> Bool {
// Here, you could write codes to navigate to the host app page.
// For best practices on navigating to the host page,
// please consult "Navigate to the host app page" below.
// Return true to customize video overlay CTA button click behavior
return true
}Customize click behaviors for shopping
To customize click behaviors for shopping, you need to set FireworkVideoShoppingDelegate delegate first:
Customize product card click behavior
Implement fireworkShopping(_:didTapProductVariant:forVideo:):
Customize shopping CTA click behavior
Implement fireworkShopping(_:productVariantCTASelected:fromVideo:ctaCompletionHandler:):
Customize product link button click behavior
Implement fireworkShopping(_:didTapLinkButtonAt:fromVideo:withURL:):
Customize cart icon click behavior
The SDK does not provide a cart page of its own. The page the user sees after tapping the cart icon is always supplied by the host app, through one of the two options below. The cart icon is also hidden by default — to show it, see Shopping configurations (iOS).
FireworkVideoSDK.shopping.cartAction determines what happens when the user taps the cart icon. There are two options.
Option 1: Show the host app cart view inside the SDK player (.showEmbeddedCart)
This is the default value of cartAction. The SDK requests a cart view controller from the host app and shows it inside the player, so the host app must supply one.
Implement
CartViewControllerProvidingto return your own cart view controller.CartViewControlleris a typealias forUIViewController & CartViewRepresentable:
Set
cartActiontoshowEmbeddedCartand assign the provider:
The cart view controller can close the drawer that contains it through
drawerController:
cartViewControllerProvider must be set for this option. If it is nil, tapping the cart icon does nothing at all.
Option 2: Handle the cart icon click in the host app (.custom)
With this option the SDK presents nothing and only notifies the host app, so the host app is free to navigate to its own page.
Set
cartActiontocustom:
Implement
fireworkShopping(_:didTapCartIconForVideo:):
If this delegate method is not implemented, tapping the cart icon does nothing at all.
Custom livestream link interaction click behavior
Set
FireworkLiveStreamBehaviorDelegatedelegate:
Implement
fireworkLiveStream(_:didTapLinkInteraction:):
Customize social attribution click behavior
Set
FireworkVideoSocialDelegatedelegate:
Implement
handleSocialAttributionClick(_:fromVideo:):
Customize video feed item click behavior
Set VideoFeedViewControllerDelegate delegate:
Implement videoFeed
(_:didTapFeedItem:):
Navigate to the Host App Page
We have three ways to navigate to the host app page when customizing click behaviors.
Present the host app page over the SDK player.
Push the host app page inside the SDK player.
Use the host app navigation controller to push the host app page.
Present the Host App Page Over the SDK Player
Use present to display the host app PDP page over the SDK player:
Push the Host App Page Inside the SDK Player
UIViewController.topNavigationController() resolves to different navigation controllers depending on the current context:
Inside the fullscreen player: returns the player's own navigation controller, so the page is pushed within the player context.
Inside a story block: falls back to the host app's navigation controller.
Because the fullscreen player hides the navigation bar, the pushed view controller must explicitly show and configure it in viewWillAppear. Using viewWillAppear (rather than viewDidLoad) is important — when the user navigates back, UIKit calls viewWillAppear on the player, allowing it to hide the bar again and restore its original state.
Use the Host App Navigation Controller to Push the Host App Page
When the fullscreen player is visible, the host app's navigation controller sits beneath it, so any page pushed directly would be obscured by the player.
FireworkVideoSDK.startPiPOrDismissFullScreenPlayer handles this by transitioning the player to a floating window (if PiP is enabled) or dismissing it (if PiP is disabled), ensuring the new page is fully visible. To always dismiss the player regardless of PiP, use FireworkVideoSDK.dismissFullScreenPlayer instead.
Last updated
Was this helpful?