View Actions Callback

The SDK supports exposing the user interaction with our internal views.
We will expand the actions we are exposing very soon.

Introducing the SPViewActionsCallbacks typealias

The SPViewActionsCallbacks is a typealias of (SPViewActionCallbackType, SPViewSourceType, String) -> Void. Means that it is a method that returns nothing and receive the following parameters:

SPViewActionCallbackType - The type of the action.
SPViewSourceType - The source view that the action took place.
String - The current post ID.

When some action will happen, the SDK will call to SPViewActionsCallbacks method with the relevant parameters.

Setting the view actions callback on a view

When using the SpotIMCoordinator to get the pre conversation or to open the full conversation, you can set the callbacks: SPViewActionsCallbacks parameter as follows:

// In your UIViewController / Source file
let callbacks: SPViewActionsCallbacks = { type, source, postId in
    switch type {
    case .articleHeaderPressed:
            // handle articleHeaderPressed action 
        print("header tapped for postId: " + postId)
    }
}

...

spotIMCoordinator?.preConversationController(
    withPostId: "POST ID",
    articleMetadata: articleMetadata,
    numberOfPreLoadedMessages: 2, // This is optional, Default = 2, Maximum = 15
    navigationController: navigationController,
    callbacks: callbacks,
    completion: { [weak self] preConversationVC in
    // add preConversationVC to your view controller
  }
)

SPViewSourceType

SPViewSourceType is the source view that the action take place.
SPViewSourceType enum options:

SPViewSourceType

Description

.preConversation

Pre-Conversation View

.conversation

Conversation View

.createComment

Create Comment View

.login

Login View

SPViewActionCallbackType

SPViewActionCallbackType is the type of view action.
SPViewActionCallbackType enum options:

SPViewActionCallbackType

Possible SPViewSourceType

Description

.articleHeaderPressed

.conversation,
.createComment

Click on article header view


Did this page help you?