> For the complete documentation index, see [llms.txt](https://docs.firework.com/firework-for-developers/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.firework.com/firework-for-developers/react-native-sdk/integration-guide-v2/customization-react-native/shopping-configurations-react-native/customize-product-card-using-the-custom-view-restricted-api.md).

# Customize product card on videos using the custom view (React Native)

## iOS

1. Create a custom view class to implement the `ProductCardViewRepresentable` protocol.

<pre class="language-swift"><code class="lang-swift">import FireworkVideo

<strong>class CustomProductView: UIView, ProductCardViewRepresentable {
</strong>    lazy var label: UILabel = UILabel(frame: .zero)
    lazy var detailsLabel: UILabel = .init(frame: .zero)
    
    /**
     Called before a product card is reused.
     - Note: This is an opportunity to clean up the product card UI elements
     */
     func prepareForReuse() {
         label.text = ""
         detailsLabel.text = ""
     }
  
     /**
      Called before a product card will be displayed on screen
      - Important: It is best to avoid network calls when this method is invoked. The product card is just moments from being rendered and network calls
      at this stage would provide a degraded user experience. Please use the hydration API to perform any product data updates.
      - Note: This is the opportunity to update the product card UI with product specific details
      - Parameters:
       - product: The product details associated to the view that will be displayed
       - video: The details of the video the product is associated with.
     */
     func updateViewForProduct(_ product: ProductCardDetails, associatedTo video: VideoDetails) {
         label.text = product.name
         detailsLabel.text = "$\(product.price.amount)"
     }
}
</code></pre>

2. Call FireworkVideoSDK.shopping.productCardViewType = CustomProductView\.self at the appropriate place, such as `application(:, didFinishLaunchingWithOptions:) -> Bool`.

```swift
import FireworkVideo

func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    FireworkVideoSDK.shopping.productCardViewType = CustomProductView.self
    
    return true
}
```

## Android

Custom product cards are disabled for the client by default. To enable this feature, the Firework SDK allows providing a custom view for the product card. This way, it is possible to have full control over the look and feel of the product card. To enable this feature, the host app should pass the following product card configuration:

```
FireworkSdk.shopping.setShoppingViewOptions(
    ShoppingViewOptions(
        theme = getProductCardsTheme(),
        productCardsOptions = ProductCardsOptions.Custom(
            widthPx = width,
            heightPx = height,
            spaceBetweenItems = spaceBetweenItems,
            cardViewStartEndPadding = padding,
            customViewProvider = { MyCustomProductCard(this) },
        ),
    ),
)
```

**Provide a view for the custom product card.** To pass a view for the custom product card, the host app should provide a `customViewProvider` parameter. This parameter is a factory function with the following signature:

```
val customViewProvider: () -> FwProductCardView
```

The function returns the implementation of `FwProductCardView`. `FwProductCardView` is an abstract class with a single abstract method that gets called when the card is inflated by FireworkSDK.

```
    abstract fun bind(product: ProductCardDetails, videoInfo: VideoInfo)
```

`ProductCardDetails` and `VideoInfo` contain information about the product and the video related to the product card. Here is an example of `FwProductCardView` implementation (initialization of the fields is omitted):

```
class MyCustomProductCard @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null, defStyle: Int = 0,
) : FwProductCardView(context, attrs, defStyle) {
    
    init {
        inflate(context, R.layout.custom_product_card_item, this)
    }

    override fun bind(product: ProductCardDetails, videoInfo: VideoInfo) {
        title.text = product.productTitle
        price.text = "${product.price?.amount ?: 0.0} ${product.price?.currencyCode}"
        Glide.with(image.context)
            .load(product.productImageUrl)
            .placeholder(R.drawable.ic_product_placeholder)
            .error(R.drawable.ic_product_placeholder)
            .into(image)
    }
}
```

**Width and height of the custom product card.** The width and height of the custom product card should be specified in pixels. The FireworkSDK can limit the size of the product card if it does not respect the safe zone. Details of the Safe Zone Specifications for Firework Videos can be found here - <https://help.firework.com/safe-zone-specifications-for-firework-videos>

**Clickable elements on the custom product card.** FireworkSDK does not allow to have clickable elements on the custom product card. If the custom product card has clickable elements, the click will be intercepted by the FireworkSDK and the default behavior will be triggered.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.firework.com/firework-for-developers/react-native-sdk/integration-guide-v2/customization-react-native/shopping-configurations-react-native/customize-product-card-using-the-custom-view-restricted-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
