Integrate SDKs in Hybrid React Native and native Apps
We support the integration of SDK components in hybrid React Native and native applications. You can utilize React Native components on React Native pages and native components on native pages. However, the host app can implement SDK global handlers or callbacks exclusively on either the React Native side or the native side.
What are the SDK handlers or callbacks?
On React Native, 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 React Native 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 React Native SDK depends on the native SDKs, installing the React Native SDK will automatically install the native SDKs as well. Please use the following code to install the React Native SDK, after which the native SDKs will also be installed.
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
.
CocoaPods could not find compatible versions for pod "FireworkVideo"
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 JS side
As shown in the following code snippets, we need to invoke markInitCalled
with directlyCallNativeInit
set to true
on the JS side.
Initialization strategy 2
If you intend to implement SDK global handlers or callbacks on the React Native side, please adopt this initialization strategy. In this approach, refer to Getting Started (React Native) to correctly install, configure, and initialize the SDK.
Use React Native Components
Regardless of the initialization strategy you choose, you can utilize React Native components on React Native pages. 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 React Native side. Please consult Analytics (React Native) 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 React Native side. Please consult Shopping (React Native) 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 (React Native) to enable support for livestream.
Last updated
Was this helpful?