SKTConversationDelegate

Objective-C

@protocol SKTConversationDelegate <NSObject>

Swift

protocol SKTConversationDelegate : NSObjectProtocol

@discussion Delegate protocol for events related to the conversation.

Creating a delegate is optional, and may be used to receive callbacks when important changes happen in the conversation.

Delegate methods are guaranteed to be called from the main thread.

  • @abstract Notifies the delegate of a change in unread message count.

    @discussion Called when conversation data is fetched from the server, or when the user enters the conversation screen.

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        unreadCountDidChange:(NSUInteger)unreadCount;

    Swift

    optional func conversation(_ conversation: SKTConversation, unreadCountDidChange unreadCount: UInt)

    Parameters

    conversation

    The conversation object that initiated the change.

    unreadCount

    The new number of unread messages.

  • @abstract Asks the delegate if an in-app notification should be shown for a message.

    @discussion Called when a new message is received, right before the in-app notification is to be shown for that message. To show your own in-app notification, return NO from this method, and use the SKTMessage object to construct your view.

    See

    SKTMessage

    Declaration

    Objective-C

    - (BOOL)conversation:(nonnull SKTConversation *)conversation
        shouldShowInAppNotificationForMessage:(nonnull SKTMessage *)message;

    Swift

    optional func conversation(_ conversation: SKTConversation, shouldShowInAppNotificationFor message: SKTMessage) -> Bool

    Parameters

    conversation

    The conversation object that initiated the change.

    message

    The message that will be displayed in the notification.

    Return Value

    YES to allow Smooch to present the notification. NO to suppress the notification, and perform custom handling.

  • @abstract Asks the delegate if the conversation should show for the given action.

    @discussion Called when the user performs an action that causes the conversation screen to show. Return NO to cancel the display of the conversation screen and perform your own handling of the action.

    See

    SKTAction

    Declaration

    Objective-C

    - (BOOL)conversation:(nonnull SKTConversation *)conversation
        shouldShowForAction:(SKTAction)action
                   withInfo:(nullable NSDictionary *)info;

    Swift

    optional func conversation(_ conversation: SKTConversation, shouldShowFor action: SKTAction, withInfo info: [AnyHashable : Any]?) -> Bool

    Parameters

    conversation

    The conversation object.

    action

    The action the user has taken.

    info

    An instance of NSDictionary with a message object with the latest SKTMessage represented as an NSDictionary

    Return Value

    YES to allow default handling. NO to suppress the conversation screen, and perform custom handling.

  • @abstract Gives the delegate the option to modify a message before it is sent

    @discussion Called when a message is about to be sent to give the delegate the option of modify or decorate its content (i.e. add metadata) before sending to Smooch. When the message type is file or image, only the message metadata may be updated. Other message properties such as type or text won’t be considered.

    Declaration

    Objective-C

    - (nonnull SKTMessage *)conversation:(nonnull SKTConversation *)conversation
                         willSendMessage:(nonnull SKTMessage *)message;

    Swift

    optional func conversation(_ conversation: SKTConversation, willSend message: SKTMessage) -> SKTMessage

    Return Value

    the message to be sent

  • @abstract Gives the delegate the option to modify a message before it is displayed. If nil is returned the message will be hidden

    @discussion Called when a message is about to be displayed to the user to give the delegate the option of modifying its content before display or hide it

    Declaration

    Objective-C

    - (nullable SKTMessage *)conversation:(nonnull SKTConversation *)conversation
                       willDisplayMessage:(nonnull SKTMessage *)message;

    Swift

    optional func conversation(_ conversation: SKTConversation, willDisplay message: SKTMessage) -> SKTMessage?

    Return Value

    the message to be displayed. If nil, the message won’t get displayed

  • @abstract Notifies the delegate of new incoming messages.

    @discussion Called when new messages are received from the server.

    See

    SKTMessage

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        didReceiveMessages:(nonnull NSArray *)messages;

    Swift

    optional func conversation(_ conversation: SKTConversation, didReceiveMessages messages: [Any])

    Parameters

    conversation

    The conversation object.

    messages

    An array of SKTMessage objects representing the new messages.

  • @abstract Notifies the delegate when older messages in the conversation history have been received

    @discussion Called when older messages in the conversation history are received from the server

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        didReceivePreviousMessages:(nonnull NSArray *)messages;

    Swift

    optional func conversation(_ conversation: SKTConversation, didReceivePreviousMessages messages: [Any])

    Parameters

    conversation

    The conversation object

    messages

    The messages that have been fetched

  • @abstract Notifies the delegate of new conversation activity

    @discussion Called when a new activity is received from the server

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        didReceiveActivity:(nonnull SKTConversationActivity *)activity;

    Swift

    optional func conversation(_ conversation: SKTConversation, didReceive activity: SKTConversationActivity)

    Parameters

    conversation

    The conversation object

    activity

    The activity that was received

  • @abstract Asks the delegate if default handling should be performed for a message action.

    @discussion Called when the user taps a message action.

    Declaration

    Objective-C

    - (BOOL)conversation:(nonnull SKTConversation *)conversation
        shouldHandleMessageAction:(nonnull SKTMessageAction *)action;

    Swift

    optional func conversation(_ conversation: SKTConversation, shouldHandle action: SKTMessageAction) -> Bool

    Return Value

    YES to allow default handling. NO to perform custom handling.

  • @abstract Notifies the delegate when the conversation is about to be presented.

    @discussion Called in the viewWillAppear: method of the conversation view controller.

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        willShowViewController:(id)viewController;

    Swift

    optional func conversation(_ conversation: SKTConversation, willShowViewController viewController: Any!)
  • @abstract Notifies the delegate when presentation of the conversation completes.

    @discussion Called in the viewDidAppear: method of the conversation view controller.

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        didShowViewController:(id)viewController;

    Swift

    optional func conversation(_ conversation: SKTConversation, didShowViewController viewController: Any!)
  • @abstract Notifies the delegate when the conversation is about to be dismissed.

    @discussion Called in the viewWillDisappear: method of the conversation view controller.

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        willDismissViewController:(id)viewController;

    Swift

    optional func conversation(_ conversation: SKTConversation, willDismissViewController viewController: Any!)
  • @abstract Notifies the delegate when dismissal of the conversation completes.

    @discussion Called in the viewDidDisappear: method of the conversation view controller.

    Declaration

    Objective-C

    - (void)conversation:(nonnull SKTConversation *)conversation
        didDismissViewController:(id)viewController;

    Swift

    optional func conversation(_ conversation: SKTConversation, didDismissViewController viewController: Any!)
  • @abstract Notifies the delegate when the conversations list was updated

    Declaration

    Objective-C

    - (void)conversationListDidRefresh:
        (nonnull NSArray<SKTConversation *> *)conversationList;

    Swift

    optional func conversationListDidRefresh(_ conversationList: [SKTConversation])

    Parameters

    NSArray<SKTConversation>

    The updated array of SKTConversation