This is the official TSL Android SDK repository.
TSL takes care of the infrastructure and APIs needed for live streaming of different types of shows for various channels. Work on your app's logic and let TSL handle live streaming of shows, sending and receiving messages, and reactions.
- Android Studio 2022+
- Android 24+
The TSL Android SDK contains external dependencies of PubNub SDK.
You will need the publish and subscribe keys to authenticate your app. Get your keys from the backend.
- You have can include Jitpack to your project by adding the following to the root build.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
- Add TSL to your project by including the following dependency to your app gradle file.
implementation "com.github.TalkShopLive:android-sdk:versionTag"
- Initialize the SDK using clientKey.
- Parameters:
-
context
: Application context. -clientKey
: Given secured client key. -debugMode
: Print console logs if true. -testMode
: Switch to staging if true. -dnt
: Switch to do not track. -callback
: Optional callback when the authentication is successful or not.
TalkShopLive.initialize(context: Context, clientKey: String, debugMode: Boolean, testMode: Boolean, dnt: Boolean)
The TSL Android SDK provides methods for fetching details of a specific show and its current event, enabling you to get show and current event details in your app.
Get detailed information about a specific show.
- Parameters:
showKey
: The unique identifier of the show.callback
: An optional callback that will be called once the show details are fetched or an error is thrown.
Show.getDetails(showKey) { error, show -> }
Get the current event of a show.
- Parameters:
showKey
: The unique identifier of the show.callback
: A optional callback that will be called once the show status is fetched or an error is thrown.
Show.getStatus(showKey) { error, show -> }
getProducts(showKey: String, preLive: Boolean, callback: ((APIClientError?, List<ProductModel>?) -> Unit)
Get the products of a specfic show.
- Parameters:
showKey
: The unique identifier of the show.isEntrance
: An optional flag indicating whether the request is related to pre products. Default is false.callback
: A callback that will be called once the show products is fetched or an error is thrown.
Show.getProducts(showKey, preLive) { error, show -> }
The Product object has a 'variants' of type JSONArray that is structured as such:
[
{
"id": 1234,
"sku": "",
"is_master": false,
"is_default": false,
"weight": "0.0",
"width": null,
"height": null,
"depth": null,
"deleted_at": null,
"created_at": "2020-12-02T23:39:08.000Z",
"updated_at": "2024-03-22T22:50:04.000Z",
"position": 1,
"limit_per_order": null,
"count_on_hand": 123,
"price": "123.12345",
"display_price": "$12.34",
"cost_price": null,
"cost_currency": "USD",
"product_id": 123,
"metadata": null,
"source_images": null,
"has_geo": false,
"allow_international": false,
"exchange_name": "",
"affiliate_link": null,
"original_price": "30.0",
"external_customer_rating": null,
"external_number_of_reviews": null,
"external_offer_id": null,
"options": [],
"buyer_price": "123.12345",
"allowed_countries": null,
"promotions": [],
"shipping_method": null,
"images": []
}
]
The TSL Android SDK provides methods for fetching user and chat details of a specific show, enabling you to chat as a guest or as a registered user in your app.
Initialize the Chat feature.
- Parameters:
context
: The application context.jwt
: The JWT token for authentication.isGuest
: Indicates whether the user is a guest.showKey
: The unique identifier of the show.callback
: An optional callback function to be invoked upon completion.
Chat(jwt, isGuest, showKey) { errorMessage, userTokenModel -> }
Publish a message to chat.
- Parameters:
message
: The message that the user wants to send.callback
: A optional callback that will be called once the message is sent or an error is thrown.
Chat.publish(message) { error, timetoken -> }
Subscribe to a chat to get notified when there are changes.
- Parameters:
callback
: A callback that will be called once there's a change.
Chat.subscribe(object : Chat.ChatCallback {
override fun onMessageReceived(message: MessageModel) {}
})
Get the chat history.
- Parameters:
count
: The number of messages to fetch. Defaults to 25.start
: The starting time token for fetching messages. Used for pagination.callback
: An optional callback to return messages, the next start token, or an error.
Chat.getChatMessages { messageList, nextStartToken, error -> }
Update the current user.
- Parameters:
count
: The new JWT tokenisGuest
: Indicates whether the user is a guest.callback
: An optional callback function to be invoked upon completion.
Chat.updateUser(jwt, isGuest) { errorMessage, userTokenModel -> }
Cleans all the connections involved with chat.
Chat.clean()
Count unread messages.
- Parameters:
callback
: Callback to return the count of unread messages.
Chat.countMessages { unreadCount -> }
Delete a message.
- Parameters:
timeToken
: The time token of the message to be deleted.callback
: An optional callback to return success or error.
Chat.deleteMessage(timeToken) { isSuccess, error -> }
Called when a new message is received.
- Parameters:
message
: TheMessageModel
instance containing the message details.
Chat.subscribe(object : Chat.ChatCallback { override fun onMessageReceived(message: MessageModel) {})
Called when a message is deleted.
- Parameters:
messageId
: Theid
of the message that has been deleted.
Chat.subscribe(object : Chat.ChatCallback { override fun onMessageDeleted(messageId: Int) {})
Called when a there is an error.
- Parameters:
error
: The error message as a string.
Chat.subscribe(object : Chat.ChatCallback { override fun onStatusChange(error: String) {})
If you need help or have a general question, contact [email protected].