Installation
Run this command:
With Flutter:
$ flutter pub add livecom_plugin
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
livecom_plugin: ^1.1.1
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:livecom_plugin/livecom_plugin.dart';
Initialize SDK
To initialize LiveCom SDK, you need pass: SDK Key, Appearence (primaryColor, secondaryColor, gradientFirstColor, gradientSecondColor) and ShareSettings(videoLinkTemplate, productLinkTemplate).
SDK Key is a unique identifier of your application that connects to LiveCom service. You can take SDK Key from your account.
With Appearance you can specify your brand's colors. In order to customize colors on Android please read this document.
ShareSettings allow you to set links for sharing videos and products.
Call the method below as soon as possible. Because it needs time to load some data.
String? liveComSDKKey;
if (Platform.isAndroid) {
liveComSDKKey = "YOUR_ANDROID_LIVECOM_SDK_KEY";
} else if (Platform.isIOS) {
liveComSDKKey = "YOUR_IOS_LIVECOM_SDK_KEY";
}
if (liveComSDKKey != null) {
_liveComPlugin.configure(
liveComSDKKey,
"0091FF",
"#EF5DA8",
"#0091FF",
"#00D1FF",
"https://website.com/{video_id}",
"https://website.com/{video_id}?p={product_id}"
);
Usage
final _liveComPlugin = LiveComPlugin();
To present screen with list of streams above current top view controller just call:
_liveComPlugin.presentStreams()
To present stream screen with specific id call:
_liveComPlugin.presentStream(streamId)
Custom Checkout and Product screens
It is possible to display your own screens for product and checkout.
- Set true in these methods:
_liveComPlugin.useCustomProductScreen = true
_liveComPlugin.useCustomCheckoutScreen = true
- Open your screen in LiveComDelegate methods:
@override
void onRequestOpenCheckoutScreen(List<String> productSKUs) {
print("[LiveCom] onRequestOpenCheckoutScreen productSKUs: " + productSKUs.join(", "));
}
@override
void onRequestOpenProductScreen(String sku, String streamId) {
print("[LiveCom] onRequestOpenProductScreen sku: " + sku + " stream_id: " + streamId);
}
- Don't forget to call
trackConversion
when user made order with your custom checkout screen:
void trackConversion(String orderId, int orderAmountInCents, String currency, List<LiveComConversionProduct> products);
Example:
_liveComPlugin.trackConversion(
"flutter_test_order_id",
1300,
"USD",
[LiveComConversionProduct("test_sku", "test_name", "stream_id", count)]
);