Open comment creation page directly
Show the create comment screen directly in your Android app.
OpenWeb allows you to open a comment creation screen with the full conversation screen below directly.
Implementation
Use the following guidance to implement this feature.
- In
onCreate()
of the application class, initialize the OpenWeb SDK with yourSpot_ID
.
SpotIm.init(
this,
"SPOT_ID"
)
SpotIm.init(
context,
"SPOT_ID"
);
- In
onCreate()
of an article activity, add the create comment to the Activity.
SpotIm.getCreateCommentIntent(context, CONVERSATION_ID, object :
SpotCallback<Intent> {
override fun onSuccess(intent: Intent) {
startActivity(intent)
}
override fun onFailure(exception: SpotException) {
//Handle error here
}
})
SpotIm.getCreateCommentIntent(context, CONVERSATION_ID, new SpotCallback<Intent>() {
@Override
public void onSuccess(Intent intent) {
startActivity(intent)
}
@Override
public void onFailure(SpotException exception) {
// Handle error here
}
});
- (Optional) In your Activity, use ConversationOptions.Builder() to create and define a
ConversationOptions
object namedoptions
and pass it toSpotIm.getCreateCommentIntent
.
val themeMode = SpotImThemeMode.DARK
val backgroundColor = Color.parseColor("#000000")
val options = ConversationOptions.Builder()
.addTheme(SpotImThemeParams(false, themeMode, backgroundColor))
.configureArticle(
Article(
"URL", "THUMBNAIL_URL", "TITLE", "SUBTITLE")
)
.addSortType(SortType.SORT_NEWEST)
.build()
SpotIm.getCreateCommentIntent(context, CONVERSATION_ID, options, object :
SpotCallback<Intent> {
override fun onSuccess(intent: Intent) {
startActivity(intent)
}
override fun onFailure(exception: SpotException) {
// Handle error here
}
})
SpotImThemeMode themeMode = SpotImThemeMode.DARK;
int backgroundColor = Color.parseColor("#00000");
SpotImThemeParams themeParams = new SpotImThemeParams(false, themeMode, backgroundColor);
ConversationOptions options = ConversationOptions.Builder()
.addMaxCountOfPreConversationComments(2)
.addTheme(themeParams)
.configureArticle(new Article(
"URL", "THUMBNAIL_URL", "TITLE", "SUBTITLE"))
.addSortType(SortType.Companion.getSORT_NEWEST())
.build()
SpotIm.getCreateCommentIntent(context, CONVERSATION_ID, options, new SpotCallback<Intent>() {
@Override
public void onSuccess(Intent intent) {
startActivity(intent)
}
@Override
public void onFailure(SpotException exception) {
// Handle error here
}
});
In case the conversation is in readOnlyMode
, only the conversation will be shown and the new comment screen won't open.
Updated about 2 months ago
Did this page help you?