ChatMessage

public class ChatMessage : LinphoneObject

An chat message is the object that is sent or received through a ChatRoom. To create a ChatMessage, use ChatRoom.createEmptyMessage(), then either add text using addUtf8TextContent() or a Content with file informations using addFileContent(). A valid Content for file transfer must contain a type and subtype, the name of the file and it’s size. Finally call send() to send it. To send files through a ChatMessage, you need to have configured a file transfer server URL with Core.setFileTransferServer(). On the receiving side, either use downloadContent() to download received files or enable auto-download in the Core using Core.setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it’s size. Keep in mind a ChatMessage created by a Basic ChatRoom can only contain one Content, either text or file.

  • Undocumented

    Declaration

    Swift

    public static func getSwiftObject(cObject: OpaquePointer) -> ChatMessage
  • Undocumented

    Declaration

    Swift

    public var getCobject: OpaquePointer? { get }
  • Direction is used to indicate if a message is outgoing or incoming.

    See more

    Declaration

    Swift

    public enum Direction : Int
  • State is used to notify if messages have been successfully delivered or not.

    See more

    Declaration

    Swift

    public enum State : Int
  • An chat message is the object that is sent or received through a ChatRoom. To create a ChatMessage, use ChatRoom.createEmptyMessage(), then either add text using addUtf8TextContent() or a Content with file informations using addFileContent(). A valid Content for file transfer must contain a type and subtype, the name of the file and it’s size. Finally call send() to send it. To send files through a ChatMessage, you need to have configured a file transfer server URL with Core.setFileTransferServer(). On the receiving side, either use downloadContent() to download received files or enable auto-download in the Core using Core.setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it’s size. Keep in mind a ChatMessage created by a Basic ChatRoom can only contain one Content, either text or file.

    Declaration

    Swift

    public func addDelegate(delegate: ChatMessageDelegate)
  • An chat message is the object that is sent or received through a ChatRoom. To create a ChatMessage, use ChatRoom.createEmptyMessage(), then either add text using addUtf8TextContent() or a Content with file informations using addFileContent(). A valid Content for file transfer must contain a type and subtype, the name of the file and it’s size. Finally call send() to send it. To send files through a ChatMessage, you need to have configured a file transfer server URL with Core.setFileTransferServer(). On the receiving side, either use downloadContent() to download received files or enable auto-download in the Core using Core.setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it’s size. Keep in mind a ChatMessage created by a Basic ChatRoom can only contain one Content, either text or file.

    Declaration

    Swift

    public func removeDelegate(delegate: ChatMessageDelegate)
  • Linphone message has an app-specific field that can store a text. The application might want to use it for keeping data over restarts, like thumbnail image path.

    Declaration

    Swift

    public var appdata: String { get set }

    Return Value

    the application-specific data or nil if none has been stored.

  • Gets the callId accociated with the message.

    Declaration

    Swift

    public var callId: String { get }

    Return Value

    the call Id

  • Returns the chatroom this message belongs to.

    Declaration

    Swift

    public var chatRoom: ChatRoom? { get }

    Return Value

    the ChatRoom in which this message has been sent or received.

  • Get the content type of a chat message.

    Declaration

    Swift

    public var contentType: String { get set }

    Return Value

    The content type of the chat message

  • Returns the list of contents in the message.

    Declaration

    Swift

    public var contents: [Content] { get }

    Return Value

    The list of Content.

  • Returns back pointer to Core object.

    Declaration

    Swift

    public var core: Core? { get }

    Return Value

    the Core object associated with this message.

  • Gets the current LinphoneChatMessageCbs. This is meant only to be called from a callback to be able to get the user_data associated with the LinphoneChatMessageCbs that is calling the callback.

    Declaration

    Swift

    public var currentDelegate: ChatMessageDelegate? { get }

    Return Value

    The LinphoneChatMessageCbs that has called the last callback.

  • Returns the real time at which an ephemeral message expires and will be deleted.

    See

    See also: isEphemeral()

    Declaration

    Swift

    public var ephemeralExpireTime: time_t { get }

    Return Value

    the time at which an ephemeral message expires. 0 means the message has not been read.

  • Returns lifetime of an ephemeral message. The lifetime is the duration after which the ephemeral message will disappear once viewed. - See also: isEphemeral()

    Declaration

    Swift

    public var ephemeralLifetime: Int { get }

    Return Value

    the lifetime of an ephemeral message, by default 86400s.

  • Get full details about delivery error of a chat message.

    Declaration

    Swift

    public var errorInfo: ErrorInfo? { get }

    Return Value

    a ErrorInfo describing the details.

  • Linphone message can carry external body as defined by rfc2017.

    Declaration

    Swift

    public var externalBodyUrl: String { get set }

    Return Value

    external body url or nil if not present.

  • Get the file_transfer_information (used by call backs to recover informations during a rcs file transfer)

    Declaration

    Swift

    public var fileTransferInformation: Content? { get }

    Return Value

    a pointer to the Content structure or nil if not present.

  • Gets the forward info if available as a string.

    Declaration

    Swift

    public var forwardInfo: String { get }

    Return Value

    the original sender of the message if it has been forwarded, nil otherwise.

  • Get origin of the message.

    Declaration

    Swift

    public var fromAddress: Address? { get }

    Return Value

    the Address of the sender.

  • Returns wether the chat message is an ephemeral message or not. An ephemeral message will automatically disappear from the recipient’s screen after the message has been viewed.

    Declaration

    Swift

    public var isEphemeral: Bool { get }

    Return Value

    true if it is an ephemeral message, false otherwise

  • Return whether or not a chat message is a file transfer.

    • deprecated: 06/07/2020 check if getContents() contains a Content for which Content.isFileTransfer() returns true.

    Declaration

    Swift

    @available(*, deprecated)
    public var isFileTransfer: Bool { get }

    Return Value

    Whether or not the message is a file transfer

  • Gets whether or not a file is currently being downloaded or uploaded.

    Declaration

    Swift

    public var isFileTransferInProgress: Bool { get }

    Return Value

    true if download or upload is in progress, false otherwise

  • Returns wether the chat message is a forward message or not.

    Declaration

    Swift

    public var isForward: Bool { get }

    Return Value

    true if it is a forward message, false otherwise

  • Returns wehther the message has been sent or received.

    Declaration

    Swift

    public var isOutgoing: Bool { get }

    Return Value

    true if message has been sent, false if it has been received.

  • Returns wether the message has been read or not.

    Declaration

    Swift

    public var isRead: Bool { get }

    Return Value

    true if message has been marked as read, false otherwise.

  • Get if the message was encrypted when transfered.

    Declaration

    Swift

    public var isSecured: Bool { get }

    Return Value

    true if the message was encrypted when transfered, false otherwise.

  • Return whether or not a chat message is a text.

    • deprecated: 06/07/2020 check if getContents() contains a Content with a PlainText content type.

    Declaration

    Swift

    @available(*, deprecated)
    public var isText: Bool { get }

    Return Value

    Whether or not the message is a text

  • Returns the local address the message was sent or received with.

    Declaration

    Swift

    public var localAddress: Address? { get }

    Return Value

    the Address of the local address used to send/receive this message.

  • Get the message identifier. It is used to identify a message so that it can be notified as delivered and/or displayed.

    Declaration

    Swift

    public var messageId: String { get }

    Return Value

    The message identifier.

  • Get the state of the message.

    Declaration

    Swift

    public var state: ChatMessage.State { get }

    Return Value

    the current State of the message.

  • Gets the text content if available as a string.

    • deprecated: 01/07/2020. Use getUtf8Text() instead.

    Declaration

    Swift

    @available(*, deprecated)
    public var textContent: String { get }

    Return Value

    the Content buffer if available in System Locale, null otherwise.

  • Get the time the message was sent.

    Declaration

    Swift

    public var time: time_t { get }

    Return Value

    the timestamp of when the message was sent.

  • Get destination of the message.

    Declaration

    Swift

    public var toAddress: Address? { get }

    Return Value

    the Address of the recipient.

  • Get if a chat message is to be stored.

    Declaration

    Swift

    public var toBeStored: Bool { get set }

    Return Value

    Whether or not the message is to be stored

  • Retrieve the user pointer associated with the chat message.

    Declaration

    Swift

    public var userData: UnsafeMutableRawPointer? { get set }

    Return Value

    The user pointer associated with the chat message.

  • Get text part of this message. Introduced in 01/07/2020

    Declaration

    Swift

    public var utf8Text: String { get set }

    Return Value

    The text in UTF8 or nil if no text.

  • Adds a content to the ChatMessage.

    Declaration

    Swift

    public func addContent(content: Content)

    Parameters

    content

    the Content object to add.

  • Add custom headers to the message.

    Declaration

    Swift

    public func addCustomHeader(headerName: String, headerValue: String?)

    Parameters

    headerName

    name of the header

    headerValue

    header value

  • Adds a file content to the ChatMessage.

    Declaration

    Swift

    public func addFileContent(content: Content)

    Parameters

    content

    the Content object to add.

  • Creates a Content of type PlainText with the given text as body.

    • deprecated: 01/07/2020. Use addUtf8TextContent() instead.

    Declaration

    Swift

    @available(*, deprecated)
    public func addTextContent(text: String)

    Parameters

    text

    The text in System Locale to add to the message.

  • Creates a Content of type PlainText with the given text as body. Introduced in 01/07/2020

    Declaration

    Swift

    public func addUtf8TextContent(text: String)

    Parameters

    text

    The text in UTF8 to add to the message.

  • Cancel an ongoing file transfer attached to this message. (upload or download)

    Declaration

    Swift

    public func cancelFileTransfer()
  • Start the download of the Content referenced in the ChatMessage from remote server.

    Declaration

    Swift

    public func downloadContent(content: Content) -> Bool

    Parameters

    content

    the Content object to download (must have the Content.isFileTransfer() method return true).

    Return Value

    false if there is an error, true otherwise.

  • Retrieve a custom header value given its name.

    Declaration

    Swift

    public func getCustomHeader(headerName: String) -> String

    Parameters

    headerName

    header name searched

    Return Value

    the custom header value or nil if not found.

  • Gets the list of participants for which the imdn state has reached the specified state and the time at which they did.

    Declaration

    Swift

    public func getParticipantsByImdnState(state: ChatMessage.State) -> [ParticipantImdnState]

    Parameters

    state

    The LinphoneChatMessageState the imdn have reached (only use LinphoneChatMessageStateDelivered, LinphoneChatMessageStateDeliveredToUser, LinphoneChatMessageStateDisplayed and LinphoneChatMessageStateNotDelivered)

    Return Value

    The list of participants.

  • Returns wether the chat message has a text content or not.

    • deprecated: 27/10/2020. Check if getContents() contains a Content for which it’s content type is PlainText.

    Declaration

    Swift

    @available(*, deprecated)
    public func hasTextContent() -> Bool

    Return Value

    true if it has one, false otherwise.

  • Fulfill a chat message char by char. Message linked to a Real Time Text Call send char in realtime following RFC 4103/T.140 To commit a message, use linphone_chat_room_send_message

    Declaration

    Swift

    public func putChar(character: UInt32) throws

    Parameters

    character

    T.140 char

    Return Value

    0 if succeed.

  • Removes a content from the ChatMessage.

    Declaration

    Swift

    public func removeContent(content: Content)

    Parameters

    content

    the Content object to remove.

  • Removes a custom header from the message.

    Declaration

    Swift

    public func removeCustomHeader(headerName: String)

    Parameters

    headerName

    name of the header to remove

  • Send a chat message.

    Declaration

    Swift

    public func send()