Open comment creation page directly

Show the create a comment screen directly in your iOS app.

This approach allows you to open a comment creation screen. When implemented, a user sees the comment creation screen directly above the full Conversation screen.

📘

If the Conversation is in readOnlyMode, only the Conversation will be shown and the new comment screen will not open.



Requirement

    OpenWeb iOS SDK



Implementation

Use the following steps to configure the Conversation:

  1. Create an instance of SpotImSDKFlowCoordinator. Make sure to have a strong reference, otherwise the instance of SpotImSDKFlowCoordinator will be deallocated.
SpotIm.createSpotImFlowCoordinator(loginDelegate: self) { [weak self] result in
    guard let self = self else { return }                                                     
        switch result {
            case .success(let coordinator):
            self.spotIMCoordinator = coordinator
            case .failure(let error):
            print(error)
        }
}

  1. Create and set SpotImArticleMetadata.
let articleMetadata = SpotImArticleMetadata(url: "URL TO THE ARTICLE PAGE                                           ON THE WEB", 
                      title: "ARTICLE TITLE", 
                      subtitle: "ARTICLE SUBTITLE", 
                      thumbnailUrl: "URL TO ARTICLE THUMBNAIL IMAGE")

  1. Open the comment creation screen by calling openNewCommentViewController on the SpotImSDKFlowCoordinator instance.

📘

Notice the fullConversationPresentationalMode. It is used to determine whether the full Conversation below will be pushed (.push) or presented (.present).

openNewCommentViewController(
  postId: self.postId,
  articleMetadata: self.metadata,
  fullConversationPresentationalMode: .push(navigationController: self.navigationController!),
  completion: completionHandler)

// Method signature:
public func openNewCommentViewController(postId: String,
                             articleMetadata: SpotImArticleMetadata,
                             fullConversationPresentationalMode: SPViewControllerPresentationalMode,
                             completion: SPOpenNewCommentCompletionHandler? = nil)

// SPViewControllerPresentationalMode enum
public enum SPViewControllerPresentationalMode {
    case present(viewController: UIViewController)
    case push(navigationController: UINavigationController)
}

  1. (Optional) Customize the Conversation.


Did this page help you?