Integrate SDKs in Hybrid Flutter and native Apps

We support the integration of SDK components in hybrid Flutter and native applications. You can utilize Flutter widgets on Flutter pages and native components on native pages. However, the host app can implement SDK global handlers or callbacks exclusively on either the Flutter side or the native side.

What are the SDK handlers or callbacks?

On Flutter, they refer to global callbacks, such as FireworkSDK.getInstance().shopping.onCustomTapProductCard.

On iOS. they refer to global delegate methods, such as fireworkShopping(_:didTapProductVariant:forVideo:).

On Android, they refer to listeners, such as FireworkSdk.shopping.setOnCtaButtonClicked.

Initialization

We have two strategies to initialize SDKs in Hybrid Flutter and native Apps.

Initialization strategy 1

If you intend to implement SDK global handlers or callbacks on the native side, please adopt this initialization strategy. The integration steps are as follows:

Install SDKs

Since the Flutter SDK depends on the native SDKs, installing the Flutter SDK will automatically install the native SDKs as well. Please use the following code to install the Flutter SDK, after which the native SDKs will also be installed.

flutter pub add fw_flutter_sdk

iOS

Run pod install in the root directory of the iOS project. And if you encountered the following issues, you could run pod update FireworkVideo FireworkVideoUI.

  1. CocoaPods could not find compatible versions for pod "FireworkVideo"

  2. CocoaPods could not find compatible versions for pod "FireworkVideoUI"

Directly configure and initialize native SDKs

Please refer to the following documentation to directly configure and initialize the native SDKs. As the native SDKs have already been installed in the previous steps, you can disregard the installation section in the following documents.

Call markInitCalled in Dart side

As shown in the following code snippets, we need to invoke markInitCalled with directlyCallNativeInit set to true on the Dart side.

FireworkSDK.getInstance().markInitCalled(directlyCallNativeInit: true);

Initialization strategy 2

If you intend to implement SDK global handlers or callbacks on the Flutter side, please adopt this initialization strategy. In this approach, refer to Getting Started (Flutter) to correctly install, configure, and initialize the SDK.

Use Flutter widgets

Regardless of the initialization strategy you choose, you can utilize Flutter widgets on the Flutter page. Please consult the following docs for further details:

Use native components

Regardless of the initialization strategy you choose, you can utilize native components on the native page. Please consult the following docs for further details:

Analytics

If you opt for initialization strategy 1, you need to receive analytics events on the native side. Please consult the following docs for further details:

If you opt for initialization strategy 2, you need to receive analytics events on the Flutter side. Please consult Analytics (Flutter) for further details.

Shopping

If you opt for initialization strategy 1, you need to customize shopping configurations and click behaviors on the native side. Please consult the following docs for further details:

If you opt for initialization strategy 2, you need to customize shopping configurations and click behaviors on the Flutter side. Please consult Shopping (Flutter) for further details.

Live Stream Support

If you opt for initialization strategy 1, please consult the following doc to enable support for livestream.

If you opt for initialization strategy 2, please consult Live Stream Support (Flutter) to enable support for livestream.

Last updated

Was this helpful?