Shopping
Callbacks
Firework SDK triggers shopping callbacks whenever appropriate to ask for product details updates, custom cart page and cart icon style, etc. It's up to the host app developer to inject custom callbacks and return feedback in the callback body. Firework SDK does not keep any state, but asks for updates via callbacks.
onUpdateProductDetails
Triggered when the video will be shown. The host app can return a Product list to update the latest product information.
onWillDisplayProduct(Only supported on iOS)
Triggered when the product will be shown. The host app can return a ProductInfoViewConfiguration object to configure configure "Add to cart" button.
onShoppingCTA
Triggered when the user clicks the shopping CTA button. And we support customizing the shopping CTA button text to "Add to cart" or "Shop now" on the iOS side. The usage codes are:
And host app can return a ShoppingCTAResult object to tell FireworkSDK the result. The event type is ShoppingCTAEvent.
onAddToCart(Deprecated)
Please use onShoppingCTA instead.
Triggered when the user clicks the "Add to cart" button. The host app can return an AddToCartResult object to tell FireworkSDK the result of adding to the cart.
onClickCartIcon
Triggered when users click the cart icon. if the host app returns NewNativeContainerProps in this callback, we will push a native container with the props when users click the cart icon. And we will render your app component with the props in the new native container.
Integration Steps
Set your app component name through
FireworkSDK.getInstance().appComponentName
. The app component name is the first parameter you pass toAppRegistry.registerComponent
. And you could set your app component name after callingAppRegistry.registerComponent
. The sample file is index.tsx.Return NewNativeContainerProps in
onClickCartIcon
callback. The sample file is HostAppShoppingService.tsx.Handle NewNativeContainerProps in your app component. The sample file is App.tsx. The version that the sample codes use for react-navigation is
6.x
. You need to handle the dynamicinitialRouteName
andinitialParams
based on the version you use.
onCustomClickCartIcon
If you don't want to handle hybrid navigation when users click the cart icon, you could set onCustomClickCartIcon
instead of onClickCartIcon
. As follows, you could start the floating player(only supported on iOS) or close the player and push the RN cart page in the RN navigation stack when users click the cart icon.
onClickCartIcon vs onCustomClickCartIcon
You could set onClickCartIcon
or onCustomClickCartIcon
callback to handle the cart icon click event. As above, onCustomClickCartIcon
is easier to integrate than onClickCartIcon
. But the two callbacks interact differently.
For onClickCartIcon
, we show a new native container to embed the React Native cart page. As the player is a native page, we need to handle hybrid navigation when implementing the onClickCartIcon
callback.
For onCustomClickCartIcon
, you could call FireworkSDK.getInstance().navigator.popNativeContainer
to close the player and navigate to the React Native cart page using React Native navigation library, such as react-navigation.
If you accept closing the player when users click the cart icon, we recommend using onCustomClickCartIcon
instead of onClickCartIcon
.
Props
cartIconVisible
Defaults to true. You can hide the cart icon by setting this property to false.
Method
setCartItemCount
Reference
Last updated