Shopping (iOS)
FireworkVideoSDK contains a shopping property that enables video shopping integration. There are two main points of integration both located on the FireworkVideoShopping type.
FireworkVideoShoppingDelegate
Assign FireworkVideoShoppingDelegate delegate to receive important shopping events.
FireworkVideoSDK.shopping.shoppingDelegate = <Your delegate>The shopping lifecycle events provide opportinities to customize the product views, hydrate product information and handle when a user adds a product variant to the cart.
Shopping configurations
Please refer to Shopping configurations (iOS).
Customize click behaviors for shopping
Please refer to Customize click behaviors for shopping.
Global Product Hydration
The fireworkShopping(_:updateDetailsForProducts:forVideo:_:) method will be called when a video will be shown that contains products. It is at this point when the host app will be able to update the associated product information. In fireworkShopping(_:updateDetailsForProducts:forVideo:_:), you could use ProductHydrating API to hydrate products. For example, you could update product names, descriptions, and variants.
func fireworkShopping(
_ fireworkShopping: FireworkVideoShopping,
updateDetailsForProducts products: [ProductID],
forVideo video: VideoDetails,
_ productHydrator: any ProductHydrating) {
// Retrieve the most up-to-date product details
// based on the product IDs from the host app server
// Introduce a delay to mimic a network request that fetches
// updated product data after the hydration callback is triggered.
DispatchQueue.global().asyncAfter(wallDeadline: .now() + 3) {
// Get product model list
let productModels = productHydrator.products
// Call hydration API
for productID in products {
productHydrator.hydrateProduct(productID) { productBuilder in
// Update product info
productBuilder
.name("Latest product name")
.description("Latest product description")
.isAvailable(true)
// Set to true to hide the product, or false to keep it visible
productBuilder.hidden(true)
// Update product variants.
// The strategy can be merge or replace.
// With merge strategy, we will merge these new variants into existing variants. We use variant id to match the variant.
// With `replace` strategy, we will replace existing variants with these new variants.
productBuilder.variants(.merge) { variantsBuilder in
// Build variant
variantsBuilder.variant("variant id1") { variantBuilder in
variantBuilder.formattedPrice(100, currencyCode: "USD")
.formattedOriginalPrice(120, currencyCode: "USD")
.url("Latest variant url1")
.imageUrl("Latest variant image url1")
.isAvailable(true)
.options([
"Color": "Latest variant color1",
"Size": "Latest variant size1"
])
return variantBuilder
}
// Build variant
variantsBuilder.variant("variant id2") { variantBuilder in
variantBuilder.name("Latest variant name2")
.formattedPrice(110, currencyCode: "USD")
.formattedOriginalPrice(130, currencyCode: "USD")
.url("Latest variant url2")
.imageUrl("Latest variant image url2")
.isAvailable(true)
.options([
"Color": "Latest variant color2",
"Size": "Latest variant size2"
])
return variantBuilder
}
return variantsBuilder
}
return productBuilder
}
}
}
}Strategy for hydrating product variants
With
mergestrategy, we will merge these new variants into existing variants. We use variant id to match the variant.With
replacestrategy, we will replace existing variants with these new variants.
Shopping error reporting
Implement fireworkShopping(_:didFailWith:) to be notified when a shopping action cannot be completed. The method has a default empty implementation, so it is optional — implement it only if you want to log or surface these failures.
FireworkVideoShoppingError has the following cases:
missingProductID
A shopping action requires a non-empty external product identifier, and the product does not have one.
missingProductUnitID
A shopping action requires a non-empty external product unit identifier, and the selected unit does not have one.
Player Deck one-tap Add to Cart
Player Deck product cards can show a one-tap Add to Cart button that adds the exact product unit shown on the card to your cart, without opening the product detail page. The SDK does not own a cart — you perform the add and report the outcome back, and the SDK animates the button accordingly.
The button is hidden by default. To enable it you must do both of the following, before the Player Deck is created:
Assign
FireworkVideoSDK.shopping.playerDeckAddToCartDelegate.Set
viewConfiguration.itemView.addToCartButton.isHidden = false.
Implement FireworkVideoPlayerDeckAddToCartDelegate to handle the request:
PlayerDeckAddToCartStatus has the following cases:
loading
The request is still in progress. Optional — report it to keep the button in its loading state.
success
The selected unit was added successfully. Terminal.
failure
The selected unit could not be added. Terminal.
SelectedProductVariant carries the product context of the tapped card:
productID
ProductID
The external identifier of the product.
unitID
UnitID
The external identifier of the exact unit to add to the cart.
url
URL?
The URL associated with the selected unit.
product
Product?
The full product model.
variant
ProductVariant?
The selected variant details, including price and availability.
Purchase tracking
The host app can record a purchase which will help get a full picture of the user journey flow. In order to do this, call FireworkVideoSDK.trackPurchase from your order confirmation (purchase complete) screen. Send every purchase event, without any client-side filtering, so Firework can identify attributed vs non-attributed purchases.
The parameters are described in the following table:
orderID
String
Yes
A unique identifier for the user's order.
orderValue
Decimal
Yes
The final amount paid, including taxes, shipping, and any discounts applied.
currencyCode
String
Yes
The ISO 4217 currency code of the purchase value.
countryCode
String?
No
The country code of the purchase.
shippingPrice
Decimal?
No
The shipping price of the order.
subtotal
Decimal
Yes
The cost of the items before discounts, taxes, and shipping.
totalDiscounts
Decimal?
No
The total discounts applied to the order.
lineItems
[LineItem]
Yes
The purchased items associated with the purchase.
additionalInfo
[String: String]?
No
Any additional information associated to the purchase.
Each LineItem has the following fields:
sku
String
Yes
The ID that can be linked back to the product or product unit. It can be the SKU, barcode, GTIN, MPN, product_unit.external_id, or product.external_id.
price
Decimal
Yes
The unit price, including line-level discounts.
quantity
Int
Yes
The product quantity.
productName
String?
No
The product variant or unit name.
Last updated
Was this helpful?