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.
onAddToCart
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 cart.
onCustomClickCartIcon
If you don't want to handle hybrid navigation when users click the cart icon, you could set onCustomClickCartIcon
. As follows, you could close the player and push the Flutter cart page in the Flutter navigation stack when users click the cart icon.
Navigate to the Flutter page from the video player
When users click the cart icon, we could navigate to the Flutter page, such as the cart page.
On the iOS side
The host app needs to return the FlutterViewController
instance in SwiftFireworkFlutterSdkPlugin.customCartPageProvdier
. The sample file is AppDelegate.swift.
On the Android side
The host app needs to set FireworkFlutterSdkPlugin.cartFragmentDelegate
and return FlutterFragment
instance in getFragment
method. The sample file is MainActivity.kt.
On the Dart side
Add route configuration for the cart page. For example, we could set the route name to
/cart
. The sample file is routes.dart.In the sample project, we add
new_native_container
(or any other custom prefix without/
) to the prefix of route name, which could avoid rendering the screen whose route name is/
in the new engine. Therefore, we need to removenew_native_container
from the route name. The sample file is my_app.dart.Custom back button of the app bar. For the new native container, we need to call
FireworkSDK.getInstance().navigator.popNativeContainer()
to pop the native container. The sample file is fw_app_bar.dart.
Properties
cartIconVisible
Defaults to true. You can hide the cart icon by setting this property to false.
Method
setCartItemCount
Reference
Last updated