Integrate SDKs in Hybrid React Native and native Apps
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
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.
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
.
We have two strategies to initialize SDKs in Hybrid React Native and native Apps.
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:
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.
npm install react-native-firework-sdk
# Or
yarn add react-native-firework-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
.
CocoaPods could not find compatible versions for pod "FireworkVideo"
CocoaPods could not find compatible versions for pod "FireworkVideoUI"
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.
As shown in the following code snippets, we need to invoke markInitCalled
with directlyCallNativeInit
set to true
on the JS side.
FireworkSDK.getInstance().markInitCalled({ directlyCallNativeInit: true });
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.
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:
Regardless of the initialization strategy you choose, you can utilize native components on the native page. Please consult the following docs for further details:
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.
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.
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.