View Actions Callback

The SPViewActionsCallbacks interface supports exposing user interactions with OpenWeb's internal views. This interface has one method: callback.


fun callback(type: SPViewActionCallbackType, source: SPViewSourceType, postId: String)
Argument NameValue
postId StringCurrent post ID of the Pre-Conversation or Conversation
source SPViewSourceTypeSource view where the action takes place

See: SPViewSourceType
type SPViewActionCallbackTypeType of view action

See: SPViewActionCallbackType

When an action occurs, the SDK calls the callback method with the relevant parameters.



Set SPViewActionsCallbacks on a view

When using the SpotIm to get the Pre-Conversation or to open the full Conversation, you can set the SPViewActionsCallbacks parameter as shown in the following example.

private val viewActionCallback = object : SPViewActionsCallbacks {
    override fun callback(type: SPViewActionCallbackType, source: SPViewSourceType, postId: String) {
        when(type) {
            is SPViewActionCallbackType.ArticleHeaderPressed -> Log.d("ViewActionCallback", "ARTICLE_HEADER_PRESSED source: " + source.value)
            is SPViewActionCallbackType.OpenUserProfile -> Log.d("ViewActionCallback", "OpenPublisherUser for user: " + type.userId)
        }
    }
}

...
  
SpotIm.getPreConversationFragment(CONVERSATION_ID,
    conversationOptions,
        object : SpotCallback<Fragment> {
        override fun onSuccess(response: Fragment) {}
        override fun onFailure(exception: SpotException) {}
        },
    viewActionCallback
)
  
SpotIm.getConversationIntent(context, CONVERSATION_ID,
    conversationOptions
    object : SpotCallback<Intent> {
        override fun onSuccess(response: Intent) {}
        override fun onFailure(exception: SpotException) {}
    },
    viewActionCallback
)


Reference

SPViewActionCallbackType

SPViewActionCallbackType is the type of view action. The following table lists the possible enums.

SPViewActionCallbackType Possible SPViewSourceType Description
ArticleHeaderPressed .CONVERSATION,
.CREATE_COMMENT
Click on article header view.
OpenUserProfile(val userId: String, val context: Context) .PRE_CONVERSATION,
.CONVERSATION
Click on profile (only when configured to receive a callback instead of opening the profile page).


SPViewSourceType

SPViewSourceType is the source view where the action takes place. The following table lists the possible enums.

SPViewSourceType Description
CONVERSATION Conversation View
CREATE_COMMENT Create Comment View
LOGIN Login View
PRE_CONVERSATION Pre-Conversation View


Did this page help you?