Firework for Developers
One-to-one Virtual ShoppingBusiness Portal
  • Welcome to Firework for Developers
  • Firework Interactive Video and One-to-many Digital Showroom
  • Web
    • Getting Started (Web)
      • Shopify
      • Magento
      • Wordpress (WooCommerce)
      • Salesforce Commerce Cloud
      • BigCommerce
    • Integration Guide for Web
      • Components
        • Hero Unit
        • Carousel / Grid
        • Storyblock (Web)
        • Player (Floating)
        • Storylink
      • Styling
      • Feed Attributes
      • Player
        • Configuration
          • Appearance
      • Video customization
        • Video Factory
        • CTA Button
        • Product cards
      • Events
        • Embed Feed and Storyblock Events
        • Video player events
        • Live stream events
        • Shopping events
      • Shopping Integration (V2)
        • Introduction
        • Shopping APIs
        • Product Hydration
        • Product Factory
        • Cart Sync
        • Tracking
          • Purchase
          • Add to cart
          • Remove from cart
          • Page viewed
        • Shopping Integration FAQ
        • Migrate from V1
      • Web SDK
      • Enhanced Picture-in-Picture
      • Privacy settings
        • Tracking settings
        • Cookies management
        • Content Security Policy
    • Telemetry console
    • Firework Service Domains
    • FAQ & Troubleshooting (Web)
  • Android SDK
    • Integration Guide for Android SDK
      • Getting Started (Android)
      • Video Feed (Android)
        • Video Feed Layouts (Android)
        • Channel Feed (Android)
        • Discover Feed (Android)
        • Playlist Feed (Android)
        • Dynamic Content Feed
        • Channel Hashtags Feed
        • Sku Feed
        • Single Content Feed
        • Configure Video Feed
      • Customization
        • CTA
      • Analytics (Android)
      • Shoppable Videos (Android)
        • Product Hydration
      • Live Stream Support (Android)
      • Video Player (Android)
      • StoryBlock (Android)
      • Share & Video Deep linking
      • Ad Support (Android)
      • Configure Video Advertisements Source (Android)
      • In-app Language Switches
      • Compose support(Android)
    • Sample App (Android)
    • FAQ & Troubleshooting (Android)
    • Changelog (Android)
  • iOS SDK
    • Integration Guide for iOS SDK
      • Getting Started (iOS)
      • ATT compliance (iOS)
      • Video Feed (iOS)
        • Discover Feed(iOS)
        • Channel Feed (iOS)
        • Playlist Feed (iOS)
        • Playlist Group Feed (iOS)
        • Dynamic Content (iOS)
        • Hashtag Playlist (iOS)
        • SKU Playlist (iOS)
        • Video Ads (iOS)
        • Video Feed Layouts (iOS)
      • Story Block (iOS)
      • Customization (iOS)
        • Video feed configurations (iOS)
        • Player configurations (iOS)
        • Shopping configurations (iOS)
          • Customize product card on videos using the custom view (iOS)
        • Customize click behaviors (iOS)
      • Shopping (iOS)
      • Live Stream Support (iOS)
      • Analytics (iOS)
      • Share & Deeplinking(iOS)
      • Ad Support (iOS)
    • Sample App (iOS)
    • FAQ & Troubleshooting (iOS)
    • Changelog (iOS)
  • React Native SDK
    • Integration Guide for React Native SDK V2
      • Getting Started (React Native)
      • ATT compliance React Native (iOS)
      • Video Feed (React Native)
      • Story Block (React Native)
      • Customization (React Native)
        • Video feed configurations (React Native)
        • Player configurations (React Native)
        • Shopping configurations (React Native)
          • Customize product card on videos using the custom view (React Native)
        • Customize click behaviors (React Native)
      • Shopping (React Native)
      • Live Stream Support (React Native)
      • Ad Support (React Native)
      • Analytics (React Native)
      • App-level Language Setting (React Native)
      • Share & Video Deeplinking (React Native)
      • Android Style (React Native)
      • Inject Android Image Loader (React Native)
      • Integrate SDKs in Hybrid React Native and native Apps
      • Reference (React Native)
      • Sample App (React Native)
      • FAQ & Troubleshooting (React Native)
      • Changelog (React Native)
  • Flutter SDK
    • Integration Guide for Flutter SDK V2
      • Getting Started (Flutter)
      • ATT compliance Flutter (iOS)
      • Video Feed (Flutter)
      • Story Block (Flutter)
      • Customization (Flutter)
        • Video feed configurations (Flutter)
        • Player configurations (Flutter)
        • Shopping configurations (Flutter)
          • Customize product card on videos using the custom view (Flutter)
        • Customize click behaviors (Flutter)
      • Live Stream Support (Flutter)
      • Shopping (Flutter)
      • Ad Support (Flutter)
      • Analytics (Flutter)
      • App-level Language Setting (Flutter)
      • Share & Video Deeplinking (Flutter)
      • Inject Android Image Loader (Flutter)
      • Android Style (Flutter)
      • Integrate SDKs in Hybrid Flutter and native Apps
      • Reference (Flutter)
      • Sample App (Flutter)
      • FAQ & Troubleshooting (Flutter)
      • Changelog (Flutter)
  • Help Articles
    • Importing Products to Firework
    • Adding products to a video
    • Displaying product videos on product pages using hashtag filtering(Web)
    • Syncing Carts
    • Encoded IDs
Powered by GitBook
On this page
  • Prerequisites
  • Installation
  • Install NPM Package
  • Setup Native Project
  • App Id Configuration
  • iOS
  • Android
  • SDK Initialization
  • iOS
  • Android
  • JS
  • Next
  • ATT compliance
  • Video Feed
  • Shopping
  • Sample Project

Was this helpful?

  1. React Native SDK
  2. Integration Guide for React Native SDK V2

Getting Started (React Native)

PreviousIntegration Guide for React Native SDK V2NextATT compliance React Native (iOS)

Last updated 23 days ago

Was this helpful?

Latest version

Prerequisites

  • Firework App Id

  • React Native 0.60 or greater.

  • iOS project

    • iOS 13 or greater.

    • Xcode 14 or greater.

    • Swift 5.7 or greater.

  • Android Project

    • JAVA_HOME 1.8 or greater

    • minSdkVersion 21 or greater

    • compileSdkVersion 31 or greater

    • targetSdkVersion = 31 or greater

    • kotlinVersion 1.8.0 or greater

Installation

Installing Firework React Native SDK requires the following step:

  1. Install NPM package

  2. Setup Native project

Install NPM Package

npm install react-native-firework-sdk
# Or
yarn add react-native-firework-sdk

Setup Native Project

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"

Android

  • build.gradle

buildscript {
  repositories {
    ...
    // This should be added
    mavenCentral()
  }
  dependencies {
    // We don’t require Gradle plugin version. Just an example.
    classpath("com.android.tools.build:gradle:4.2.2")
    ...
  }
}

allprojects {
  repositories {
    ...
    mavenCentral()
  }
}
  • gradle-wrapper.properties

...
# We don’t require Gradle version. Just an example.
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
...
  • app/build.gradle

...
apply from: 'firework.gradle'
  • add android:windowSoftInputMode="adjustPan" to the file app/src/Androidmanifest.xml if there is a story block in your app and use the live stream

    <application
        android:name=".MainApplication"
        ...>
        <activity
            android:name=".MainActivity"
            ...
            android:windowSoftInputMode="adjustPan">
        </activity>
    </application>
  • New file: app/firework.gradle

android {
  packagingOptions {
    exclude 'META-INF/*.kotlin_module'
  }
}

dependencies {
  implementation "com.firework:sdk:+"
  // Uncomment the next line if you want to integrate the single-host live stream
  // implementation "com.firework.external.livestream:singleHostPlayer:+"
  // Uncomment the next line if you want to integrate the multi-host live stream
  // implementation "com.firework.external.livestream:multiHostPlayer:+"
}

configurations.all {
  resolutionStrategy.eachDependency { details ->
    if (details.requested.group == 'com.firework' && details.requested.name == 'sdk') {
      details.useVersion rootProject.ext.get("fwNativeVersion")
    }
    if (details.requested.group == 'com.firework.external.livestream' && details.requested.name == 'singleHostPlayer') {
      details.useVersion rootProject.ext.get("fwNativeVersion")
    }
    if (details.requested.group == 'com.firework.external.livestream' && details.requested.name == 'multiHostPlayer') {
      details.useVersion rootProject.ext.get("fwNativeVersion")
    }
  }
}

App Id Configuration

iOS

Include the app ID in your app Info.plist file using the key FireworkVideoAppID .

See the image below:

Android

Include the appid in your app AndroidManifest.xml file, like below:

  <application
    ...
  >
    <activity .../>
    ...
    
    // Include the app ID
    <meta-data
      android:name="Firework:Appid"
      android:value="your firework appid" />
  </application>

SDK Initialization

iOS

In your iOS project, you need to call FWReactNativeSDK.initializeSDK(nil) in application(:, didFinishLaunchingWithOptions:) -> Bool method.

import react_native_firework_sdk

func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
    FWReactNativeSDK.initializeSDK(nil)
    
    return true
}

If your AppDelegate class is written by Objective-C, you should create a Swift file to call the API. For example, you could create FireworkSupportLibraryBridge.swift and add the following codes.

import react_native_firework_sdk

@objc
public class FireworkSupportLibraryBridge: NSObject {
  @objc public static func initFireworkSDK() {
      FWReactNativeSDK.initializeSDK(nil)
  }
}

Then add [FireworkSupportLibraryBridge initFireworkSDK]; on application:didFinishLaunchingWithOptions: method.

// You should change the file to Objective-C Generated Interface Header name.
// Generally, it's "{TargetName}-Swift.h"
#import "FireworkSdkExample-Swift.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [FireworkSupportLibraryBridge initFireworkSDK];
  return YES;
}

iOS initialization options

We support passing an option to the SDK initialization method. The sample codes are:

FWReactNativeSDK.initializeSDK(
    SDKInitOptions(
        videoLaunchBehavior: .muteOnFirstLaunch
    )
)

The SDK init option structure is:

public struct SDKInitOptions: Codable {
    public var userId: String?
    public var videoLaunchBehavior: FWRVideoLaunchBehavior?
    public init(userId: String? = nil, videoLaunchBehavior: FWRVideoLaunchBehavior? = nil) {
        self.userId = userId
        self.videoLaunchBehavior = videoLaunchBehavior
    }
}

Android

Step 1: Add the FWReactNative.init method to your MainApplication class.

class MainApplication: xxxx {

  override fun onCreate() {
    super.onCreate()
    // ...
    FWReactNativeSDK.INSTANCE.init(
      this,
      new FWSDKInitOptionsModel(null, FWPlayerLaunchBehavior.MuteOnFirstLaunch)
    );
    // ...
  }
}
    // If you have the modules below, you need to add the modules before the SDK init method
    //    FWReactNativeSDK.INSTANCE.addLivestreamPlayerInitializer(new SingleHostLivestreamPlayerInitializer());
    //    FWReactNativeSDK.INSTANCE.addLivestreamPlayerInitializer(new MultiHostLivestreamPlayerInitializer());
    //    FWReactNativeSDK.INSTANCE.setImageLoader(GlideImageLoaderFactory.INSTANCE.createInstance(this));
    //    FWReactNativeSDK.INSTANCE.setImageLoader(PicassoImageLoaderFactory.INSTANCE.createInstance(this));

    FWReactNativeSDK.INSTANCE.init(
      this,
      new FWSDKInitOptionsModel(null, FWPlayerLaunchBehavior.MuteOnFirstLaunch)
    );

Android initialization options

We support passing an option to the SDK initialization method. The sample codes are:

    FWReactNativeSDK.INSTANCE.init(
      this,
      new FWSDKInitOptionsModel(null, FWPlayerLaunchBehavior.MuteOnFirstLaunch)
    );

The SDK init option structure is:

data class FWSDKInitOptionsModel(
  val userId: String? = null,
  val videoLaunchBehavior: FWPlayerLaunchBehavior? = null,
)

JS

Call FireworkSDK.getInstance().markInitCalled() on the JS side.

import FireworkSDK from 'react-native-firework-sdk';

/*
  Optional: set listener for SDK init
*/
FireworkSDK.getInstance().onSDKInit = (event) => {
  console.log('onSDKInit', event);
};

/* 
  Although we call the initialization method on the native side,
  we also need to mark the initialization method as being called on the JS side.
*/
FireworkSDK.getInstance().markInitCalled();

Please don't call FireworkSDK.getInstance().init() on the JS side anymore.

Next

ATT compliance

Video Feed

Shopping

Sample Project

Step 2: Please check the section. Choose an image loader( or ) that works for you. If you're not sure which one to use, Glide image loader is recommended.

To ensure compliance with Apple privacy guidelines and regulations, we don't track data if users don't allow it. Please refer to .

If you want to integrate a video feed, please follow the instruction .

If you want to integrate video shopping, please follow the instruction .

We provide a on Github.

release notes
ATT compliance React Native (iOS)
here
here
sample project
Inject Image Loader
Glide
Picasso