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 }
-
See moreDirection
is used to indicate if a message is outgoing or incoming.Declaration
Swift
public enum Direction : Int
-
See moreState
is used to notify if messages have been successfully delivered or not.Declaration
Swift
public enum State : Int
-
An chat message is the object that is sent or received through a
ChatRoom
. To create aChatMessage
, use ChatRoom.createEmptyMessage(), then either add text using addUtf8TextContent() or aContent
with file informations using addFileContent(). A validContent
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 aChatMessage
, 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 theCore
using Core.setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it’s size. Keep in mind aChatMessage
created by aBasic
ChatRoom
can only contain oneContent
, 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 aChatMessage
, use ChatRoom.createEmptyMessage(), then either add text using addUtf8TextContent() or aContent
with file informations using addFileContent(). A validContent
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 aChatMessage
, 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 theCore
using Core.setMaxSizeForAutoDownloadIncomingFiles(), -1 disabling the feature and 0 always downloading files no matter it’s size. Keep in mind aChatMessage
created by aBasic
ChatRoom
can only contain oneContent
, 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
-
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
-
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.
-
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.
-
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.
-
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
- deprecated: 06/07/2020 check if getContents() contains a
-
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
- deprecated: 06/07/2020 check if getContents() contains a
-
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.
-
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 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.
-
Add custom headers to the message.
Declaration
Swift
public func addCustomHeader(headerName: String, headerValue: String?)
Parameters
headerName
name of the header
headerValue
header value
-
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/2020Declaration
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 theChatMessage
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.
- deprecated: 27/10/2020. Check if getContents() contains a
-
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 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()