Comments
Use Comments to allow your audience to add their comments and reply to others on any feature or topic in your experience.
Comments Service
The comments service enables app developers to add comments to anything in their experience. By creating comment boards and associating those boards with content in your app, you enable users to add comments and replies to that content. Some use cases for the comments service include:
- Comments on blog posts
- Reactions to videos
- Fan discussion of teams and players
Glossary
- Board: resource that represents a topic to comment on. Clients associate boards to their blog posts, videos, teams, individual sports matches, and so on.
- Comment: resource that represents a post made to a board. Comments have IDs, authors, contents, and timestamps. Comments can be posted directly to a board, or in response to another comment. Comments that respond to other comments are called replies.
- Reply: a comment posted in direct response to another comment.
Working with Comment Boards
Comment Board related APIs can be accessed with the help of the CommentBoardClient
. The CommentBoardClient
is a part of the EngagementSDK
and can be accessed using an instance of the same.
boards = liveLikeEngagementSDK.commentBoard()
let sdk: EngagementSDK
sdk.commentBoards
Creating a Comment Board
Users can create a Comment Board using the createCommentBoard
method which is a part of the CommentBoardClient
. It accepts an object of type CreateCommentBoardRequestOptions
which lists all the parameters needed to create the Comment Board
for use.
boards.createCommentBoard(
CreateCommentBoardRequestOptions(
customId = "",
title = "",
allowComments = true,
replyDepth = 1,
customData = "",
description = ""
),
object: LiveLikeCallback <
CommentBoard >
() {
override fun onResponse(
result: CommentBoard ? ,
error : String ?
) {
...
}
}
)
let sdk: EngagementSDK
let createBoardOptions = CreateCommentBoardRequestOptions(
title: "",
customID: "",
allowComments: true,
repliesDepth: 1
)
sdk.commentBoards.createCommentBoard(
createCommentBoardOptions: createBoardOptions
) { result in
switch result {
case .success(let commentBoard):
// handle success
case .failure(let error):
// handle failure
}
}
LiveLike.createCommentBoard({
title: 'sd',
customId: 'postid1',
repliesDepth: 2,
allowComments: true,
description: 'desc',
customData: 'abc',
}).then((commentBoard) => console.log(commentBoard));
Updating a Comment Board
Users can update a Comment Board using the updateCommentBoard
method which is a part of the CommentBoardClient
. It accepts an object of type UpdateCommentBoardRequestOptions
which lists all the parameters that can be updated for the Comment Board
.
boards.updateCommentBoard(
UpdateCommentBoardRequestOptions(
commentBoardId = "",
customId = "",
title = "",
allowComment = true,
replyDepth = 1,
customData = "",
val description = ""
),
object: LiveLikeCallback < CommentBoard > () {
override fun onResponse(
result: CommentBoard ? ,
error : String ?
) {
...
}
}
)
let sdk: EngagementSDK
let updateBoardOptions = UpdateCommentBoardRequestOptions(
title: "",
customID: "",
allowComments: true,
repliesDepth: 1
)
sdk.commentBoards.updateCommentBoard(
commentBoardID: "",
updateCommentBoardOptions: updateBoardOptions
) { result in
switch result {
case .success(let commentBoard):
// handle success
case .failure(let error):
// handle failure
}
}
LiveLike.updateCommentBoard({
commentBoardId: '5f5fea99-569b-42f3-875d-5b3943b64ba0',
title: 'title',
customId: 'postID431',
repliesDepth: 1,
allowComments: true,
description: 'abc',
customData: 'custom data',
}).then((commentBoard) => console.log(commentBoard));
Getting a list of Comments Boards
boards.getCommentBoards(
LiveLikePagination.FIRST,
object : LiveLikeCallback<List<CommentBoard>>() {
override fun onResponse(result: List<CommentBoard>?, error: String?) {
}
}
)
let sdk: EngagementSDK
sdk.commentBoards.getCommentBoards(
page: .first
) { result in
switch result {
case .success(let commentBoards):
// handle success
case .failure(let error):
// handle failure
}
}
LiveLike.getCommentBoards().then(({results}) => console.log(results))
Deleting a Comment Board
boards.deleteCommentBoards(
DeleteCommentBoardRequestOptions(commentBoardId = ""),
object : LiveLikeCallback<LiveLikeEmptyResponse>() {
override fun onResponse(result: LiveLikeEmptyResponse?, error: String?) {
}
}
)
let sdk: EngagementSDK
sdk.commentBoards.deleteCommentBoard(
commentBoardID: ""
) { result in
switch result {
case .success:
// handle succes
case .failure(let error):
// handle failure
}
}
deleteCommentBoard({
commentBoardId: 'aa7e03fc-01f0-4a98-a2e0-3fed689632d7',
}).then(({ results }) => console.log(results));
Working with Comments
Comments related APIs can be accessed with the help of the CommentClient
. The CommentClient
is linked to a Comment Board
and can be initialized using the createCommentClient
method in the EngagementSDK
. It requires the commentBoardID
as a parameter which gives the user access to the following APIs after initialization.
private var activeCommentSession: LiveLikeCommentClient? = null
activeCommentSession = activeCommentBoard.id ? .let {
commentBoardId - >
liveLikeEngagementSDK.comment(
commentBoardId
)
}
let sdk: EngagementSDK
sdk.createCommentClient(
for: ""
) { result in
switch result {
case .success(let commentClient):
// store `commentClient` for later usage
case .failure(let error):
//handle failure
}
}
Creating a Comment
activeCommentSession.addComment(
AddCommentRequestOptions(
text = "",
customData = ""
), object: LiveLikeCallback < Comment > () {
override fun onResponse(result: Comment ? , error : String ? ) {
...
}
}
)
let commentClient: CommentClient
commentClient.addComment(
text: ""
) { result in
switch result {
case .success(let comment):
// handle success
case .failure(let error):
// handle failure
}
}
Reply to a Comment
activeCommentSession.addCommentReply(
AddCommentReplyRequestOptions(
parentCommentId = "",
text = "",
customData = ""
), object: LiveLikeCallback < Comment > () {
override fun onResponse(result: Comment ? , error : String ? ) {
...
}
}
)
let commentClient: CommentClient
commentClient.addCommentReply(
parentCommentID: "",
text: ""
) { result in
switch result {
case .success(let comment):
// handle success
case .failure(let error):
// handle failure
}
}
Get a list of Top Level Comments
Integrator can filter top level comments with filters like:
NEWEST ,OLDEST,
OLDEST_REPLIES(Comments with oldest reply),
NEWEST_REPLIES(Comments with newest reply),
repliedSince(Get comments with reply since timestamp ),
repliedUntil (Get comments with reply until timestamp )
activeCommentSession.getComments(
GetCommentsRequestOptions(
CommentSortingOptions.NEWEST,
CommentSortingOptions.NEWEST_REPLIES,
repliedSince=""),
LiveLikePagination.FIRST,
object: LiveLikeCallback < List < Comment >> () {
override fun onResponse(
result: List < Comment > ? ,
error : String ?
) {
...
}
}
)
let commentClient: CommentClient
commentClient.getCommentsList(
page: .first
) { result in
switch result {
case .success(let comments):
// handle success
case .failure(let error):
// handle failure
}
}
Get a list of Replies to a Comment
activeCommentSession.getCommentReplies(
GetCommentRepliesRequestOptions(commentId = “”,
CommentSortingOptions.NEWEST),
LiveLikePagination.FIRST,
object: LiveLikeCallback < List < Comment >> () {
override fun onResponse(
result: List < Comment > ? ,
error : String ?
) {
...
}
}
)
let commentClient: CommentClient
let options = GetCommentRepliesListRequestOptions(
commentBoardID: "",
parentCommentID: ""
)
commentClient.getCommentRepliesList(
options: options,
page: .first
) { result in
switch result {
case .success(let comments):
// handle success
case .failure(let error):
// handle failure
}
}
Edit a Comment
activeCommentSession.editComment(
UpdateCommentRequestOptions(
commentId = "", text = ""
),
object: LiveLikeCallback < Comment > () {
override fun onResponse(
result: Comment ? ,
error : String ?
) {
...
}
}
)
let commentClient: CommentClient
commentClient.editComment(
commentID: "",
text: ""
) { result in
switch result {
case .success(let comment):
// handle success
case .failure(let error):
// handle failure
}
}
Delete a Comment
activeCommentSession.deleteComment(
DeleteCommentRequestOptions(
commentId = ""
),
object: LiveLikeCallback < LiveLikeEmptyResponse > () {
override fun onResponse(
result: LiveLikeEmptyResponse ? ,
error : String ?
) {
...
}
}
)
let commentClient: CommentClient
commentClient.deleteComment(
commentID: ""
) { result in
switch result {
case .success(let comment):
// handle success
case .failure(let error):
// handle failure
}
}
Updated about 1 month ago