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.
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:
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,
)
Step 2: Please check the Inject Image Loader section. Choose an image loader(Glide or Picasso) that works for you. If you're not sure which one to use, Glide image loader is recommended.
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.
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.