View Actions Callback
SPViewActionsCallbacks
supports exposing user interactions with OpenWeb's internal views. SPViewActionsCallbacks
is a typealias
of the following:
(SPViewActionCallbackType, SPViewSourceType, String) -> Void
Argument Name | Value |
---|---|
SPViewActionCallbackType | Type of view action See: SPViewActionCallbackType |
SPViewSourceType | Source view where the action takes place See: SPViewSourceType |
String | Current post ID of the Pre-Conversation or Conversation |
This method returns nothing. When an action occurs, the SDK calls the SPViewActionsCallback
method with the relevant parameters.
Set SPViewActionsCallbacks 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 shown in the following example.
// 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
}
)
Reference
SPViewActionCallbackType
SPViewActionCallbackType
is the type of view action. The following table lists the possible enums.
SPViewActionCallbackType | Possible SPViewSourceType | Description |
---|---|---|
.articleHeaderPressed |
.conversation ,.createComment |
Click on article header view. |
.openUserProfile(userId: String, navigationController: UINavigationController) |
.preConversation ,.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 |
.createComment |
Create Comment View |
.login |
Login View |
.preConversation |
Pre-Conversation View |
Updated 8 months ago