The SDK provides behavior delegate methods to customize click behaviors, including those for the video CTA button, product cards, and shopping CTA button.
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
}
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.
Customize click behaviors for shopping
To customize click behaviors for shopping, you need to set FireworkVideoShoppingDelegate delegate first:
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
didTapProductVariant item: SelectedProductVariant,
forVideo 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 product card click behavior
return true
}
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
productVariantCTASelected item: SelectedProductVariant,
fromVideo video: VideoDetails,
ctaCompletionHandler: @escaping ShoppingCTAHandler
) {
// 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.
// Calling completion closure with none refer to
// host app will customize the click behavior
ctaCompletionHandler(.none)
}
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
didTapLinkButtonAt item: SelectedProductVariant,
fromVideo video: VideoDetails,
withURL itemURL: String
) -> 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 product link button click behavior
return true
}
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
didTapCartIconForVideo videoDetails: VideoDetails
) {
// 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.
}
func fireworkLiveStream(
_ liveStream: LiveStreamEventDetails,
didTapLinkInteraction interaction: LiveStreamLinkInteraction
) -> 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 livestream link interaction click behavior
return true
}
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.
Use the host app navigation controller to push the host app page.
Present the host app page
As the following code snippets, we use "present" to navigate to the host app PDP page. The code snippets are:
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
didTapProductVariant item: SelectedProductVariant,
forVideo video: VideoDetails
) -> Bool {
// The following PDP view controller is a sample.
// Please create your own PDP view controller.
let pdpVC = UIViewController()
// As we may have other flows in PDP(such as the checkout page),
// we could embed the PDP controller with navigation controller.
let nav = UINavigationController(rootViewController: pdpVC)
nav.modalPresentationStyle = .fullScreen
UIViewController.topPresentedVC()?.present(nav, animated: true)
// Return true to customize product card click behavior
return true
}
Use the host app navigation controller to push the host app page
When the SDK fullscreen player is displayed, the host app's navigation controller is positioned beneath it. When the host app navigates to a new page using its navigation controller while customizing click behaviors, it will be obscured by the Firework full-screen player.
As illustrated in the following code snippets, you can invoke our APIs to convert the Firework full-screen player (if it exists) into a floating player or close it (if it exists) when customizing click behaviors. This approach ensures that the new host app page will not be obscured by the Firework full-screen player.
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
didTapProductVariant item: SelectedProductVariant,
forVideo video: VideoDetails
) -> Bool {
// Use the following codes to convert the Firework full-screen player (if it exists)
// into a floating player or close it
do {
try PictureInPictureController.start()
} catch {
FireworkVideoSDK.dismissFullScreenPlayer()
}
// Use host app navigation controller to push the host app page
if let nav = FireworkVideoSDK.getHostAppNavigationController() {
// The following PDP view controller is a sample.
// Please create your own PDP view controller.
let pdpVC = UIViewController()
nav.pushViewController(pdpVC, animated: true)
return true
}
return false
}
The above code snippets are based on fireworkShopping(_:didTapProductVariant:forVideo:). But they are also applicable to other behavior delegate methods.
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.
You could write codes to navigate to the host app page within the delegate method. For best practices on navigating to the host page, please consult page below.