Integrate SDKs in Hybrid React Native and native Apps
Last updated
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. SDK global handlers and callbacks are implemented on the native side, so your existing native integration code continues to drive shopping behavior, analytics, and other global events across both React Native and native pages.
This guide is written for the common case: you have an existing native app with the Firework iOS/Android SDK integrated, and you are adding React Native pages to it. With this approach, all your existing native SDK integration code (handlers, callbacks, shopping configurations, analytics listeners, etc.) keeps working as-is — you only need to add the React Native SDK on top.
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-sdkiOS
Run pod install in the root directory of the iOS project. If you encounter the error CocoaPods could not find compatible versions for pod "FireworkVideo", run pod update FireworkVideo instead.
Follow the native SDK guides below to configure and initialize the SDK on each platform. The native SDKs are already installed via the React Native SDK in the previous step, so you can skip the installation sections in these guides.
As shown in the following code snippet, we need to invoke markInitCalled with directlyCallNativeInit set to true on the JS side.
You can utilize React Native components on React Native pages. Please consult the following docs for further details:
You can utilize native components on the native page. Please consult the following docs for further details:
Receive analytics events on the native side. Please consult the following docs for further details:
Customize shopping configurations and click behaviors on the native side. Please consult the following docs for further details:
To enable support for livestream, please consult the following docs:
Last updated
Was this helpful?
Was this helpful?
FireworkSDK.getInstance().markInitCalled({ directlyCallNativeInit: true });