Android
Basic
Integration

This is a developers' guide for setting up a LiveLike SDK configuration for native Android apps. We will take you through the basic technical steps for configuration and show you how to send your first widgets and chat messages. We will also provide detailed samples and instructions for a complete LiveLike integration.

Prerequisites

  • An admin login and registered application on the Producer Site
  • Client ID - Used to initialize the SDK. To get your ClientID, register your application in the Producer Site
  • Minimum OS: Android 4.1
  • Minimum Android SDK: Jelly Bean SDK 16

Installation

Current Version is 0.1.3

Step 1

Add the JitPack repository to your build file

allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
< repositories>
            < repository>
                < id>jitpack.io< /id>
                < url>https://jitpack.io< /url>
            < /repository>
        < /repositories>
resolvers += "jitpack" at "https://jitpack.io"
:repositories [["jitpack" { :url "https://jitpack.io" }]]

Step 2

Add the dependency

implementation 'org.bitbucket.livelike.livelike-android-sdk:engagementsdk:0.1.3'
< dependency>
        < groupId>org.bitbucket.livelike.livelike-android-sdk< /groupId>
        < artifactId>engagementsdk< /artifactId>
        < version>0.1.3< /version>
    < /dependency>
libraryDependencies += "org.bitbucket.livelike.livelike-android-sdk" % "engagementsdk" % "0.1.3"
:dependencies [[org.bitbucket.livelike.livelike-android-sdk/engagementsdk "0.1.3"]]

Initialization

For this step, you will need your Client ID to initialize the Engagement SDK. To get your ClientID:

  1. Login to the Producer Site.
  2. Under your profile picture select 'My Organizations' from the dropdown menu.
  3. You will see your Client ID under any app available in the 'Apps' section.
  4. You can also pass user access-token (optional parameter) during sdk initialisation or sdk will create new user.
  5. SDK exposes LiveLikeUser stream to get user and access-token persist at client app for future SDK init calls.
if(userAccessToken == null){
    val engagementSDK = LiveLikeSDK(BuildConfig.LIVELIKE_CLIENT_ID, applicationContext)
    engagementSDK.userStream.subscribe("key"){
           it?.let { persistUserToken(it.accessToken) } 
        }
 }else{
   val engagementSDK = LiveLikeSDK(BuildConfig.LIVELIKE_CLIENT_ID, applicationContext,userAccessToken)
 }
if(userAccessToken == null){
  LiveLikeSDK engagementSDK = new LiveLikeSDK(BuildConfig.LIVELIKE_CLIENT_ID, applicationContext);
  engagementSDK.getUserStream.subscribe("key",new Function1() {
            @Override
            public Unit invoke(LiveLikeUserApi liveLikeUserApi) {
               return persistToken(liveLikeUserApi.getAccessToken());
            }
        }
 }else{
   LiveLikeSDK engagementSDK = new LiveLikeSDK(BuildConfig.LIVELIKE_CLIENT_ID, applicationContext,userAccessToken)
 }

Configure your Layout

Now you have to configure your media page layout and declare containers for the Engagement SDK Widget and Chat views to live inside.

Even though this guide makes use of both the chat and widget components, it is possible to use only one of the components, if desired.

Add the following to your layout XML

< com.livelike.livelikesdk.chat.ChatView
    android:id="@+id/chat_view"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"/ >
            
< com.livelike.livelikesdk.widget.view.WidgetView
    android:id="@+id/widget_view"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"/ >
  • displayUserProfile property is used to control the display of user profile bar above chat input box.
  • properties of view can be set via xml or programatically.

Starting A Content Session

A Content Session represents a user's subscription to a particular program (typically a live, linear TV show, game or episode). To start a Content Session you will need a Program ID. Integrating teams are expected to create programs within the LiveLike system, either through the API or through the CMS. The team should then copy the Program IDs into the relevant media metadata in their own systems, so that content sessions can be started along with media playback.

How to create Program ID

How to publish a widget

val session = engagementSDK.createContentSession("< program-id >")
widget_view.setSession(session)
chat_view.setSession(session)
ContentSession session = engagementSDK.createContentSession("< program-id>");
WidgetView widgetView = findViewById(R.id.widgetView);
widgetView.setSession(session);
ChatView chatView = findViewById(R.id.chatView);
chatView.setSession(session);

Closing Content Session

When the user returns to your application's home page and away from your live video screen you will want to close the ContentSession. Closing a session will disconnect from Widgets and Chat and release all the related resources .

session.close()
session.close()

Contacting LiveLike Support

If you've been unable to solve your problem with the help of the sections above, please feel free to contact the LiveLike support team at support@livelike.com.