# 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.

```sh
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.

1. [Getting Started (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/getting-started)
2. [Getting Started (Android)](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/getting-started)

#### 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.

```dart
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)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/getting-started) 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:

1. [Video Feed (Flutter)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/video-feed)
2. [Story Block (Flutter)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/story-block)

## 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:

1. [Video Feed (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/video-feed)
2. [Story Block (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/storyblock)
3. [Video Feed (Android)](https://github.com/loopsocial/gitbook-docs/blob/master/android-sdk/integration-guide/video-feed/README.md)
4. [StoryBlock (Android)](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/storyblock)

## 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:

1. [Analytics (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/analytics)
2. [Analytics (Android)](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/analytics)

If you opt for **initialization strategy 2**, you need to receive analytics events on the **Flutter side**. Please consult [Analytics (Flutter)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/analytics) 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:

1. [Shopping (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/shopping-ios)
2. [Shoppable Videos (Android)](https://docs.firework.com/firework-for-developers/android-sdk/integration-guide/shoppable-videos)

If you opt for **initialization strategy 2**, you need to customize shopping configurations and click behaviors on the **Flutter side**. Please consult [Shopping (Flutter)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/shopping) for further details.

## Live Stream Support

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

1. [Live Stream Support (iOS)](https://docs.firework.com/firework-for-developers/ios-sdk/integration-guide-for-ios-sdk/live-stream-support)
2. [Live Stream Support (Android)](https://github.com/loopsocial/gitbook-docs/blob/master/android-sdk/integration-guide/live-stream-support-android.md)

If you opt for **initialization strategy 2**, please consult [Live Stream Support (Flutter)](https://docs.firework.com/firework-for-developers/flutter-sdk/integration-guide-v2/live-stream-support) to enable support for livestream.
