Getting Started

Prerequisites

  • Firework App Id

  • React Native 0.60 or greater.

  • iOS project

    • iOS 12 or greater.

    • Xcode 13 or greater.

    • Swift 5.5 or greater.

  • Android Project

    • JAVA_HOME 1.8 or greater

    • minSdkVersion 21 or greater

    • compileSdkVersion 30 or greater

    • targetSdkVersion = 30 or greater

    • kotlin_version 1.5.10

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@1.11.1
#or
yarn add react-native-firework-sdk@1.11.1

Setup Native Project

iOS

Run pod install in the root directory of the iOS project. And we also need to re-run pod install when upgrading the RN SDK version.

Android

  • build.gradle

buildscript {
  repositories {
    ...
    maven { url "https://jitpack.io" }
  }
  dependencies {
    // We don’t require Gradle plugin version. But we suggest using 4+.
    classpath("com.android.tools.build:gradle:4.0.1")
    ...
  }
}

allprojects {
  repositories {
    ...
    maven { url 'https://www.jitpack.io' }
  }
}
  • gradle-wrapper.properties

...
# We don’t require Gradle version. But we suggest using 6+.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
...
  • app/build.gradle

...
apply from: 'firework.gradle'
  • New file: app/firework.gradle

android {
  dataBinding {
    enabled = true
  }
  
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
    exclude("META-INF/*.kotlin_module")
  }
}

dependencies {
  // ads
  implementation 'com.github.loopsocial:AndroidAdsService:v20.0.0'
//  implementation 'com.github.loopsocial:AndroidAdsService:v19.5.0'

  // will crash on Android 12 API 31 if your targetSdkVersion is 31 and the work-runtime-ktx version smaller than 2.7.0
  // Please use the work-runtime-ktx version greater than or equal to 2.7.0 if your targetSdkVersion is 31
//  implementation 'androidx.work:work-runtime-ktx:2.7.0'
}

// AAPT: error: resource android:attr/lStar not found
// solution 1: some library may dependent on 1.7.x, you can force it to 1.6.0
// solution 2: upgrade compileSdkVersion and targetSdkVersion to 31
configurations.all {
  resolutionStrategy {
    force 'androidx.core:core-ktx:1.6.0'
    force 'androidx.core:core:1.6.0'
  }
}

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

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

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

/* 
  It is recommended to call the init method when the application starts, 
  e.g. in the index.tsx. Init method has one optional parameter: userId. 
*/
FireworkSDK.getInstance().init();

Video Feed

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

Shopping

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

Sample Project

We provide a sample project on Github.

Last updated