IMConversation
public class IMConversation
IM Conversation
-
Undocumented
Declaration
Swift
public typealias RawData = [String : Any]
-
The client which this conversation belong to.
Declaration
Swift
public private(set) weak var client: IMClient? { get }
-
The ID of the conversation.
Declaration
Swift
public let ID: String
-
The ID of the client.
Declaration
Swift
public let clientID: IMClient.Identifier
-
Indicates whether the conversation is unique.
Declaration
Swift
public let isUnique: Bool
-
The unique ID of the unique conversation.
Declaration
Swift
public let uniqueID: String?
-
The name of the conversation.
Declaration
Swift
public var name: String? { get }
-
The creator of the conversation.
Declaration
Swift
public var creator: String? { get }
-
The creation date of the conversation.
Declaration
Swift
public var createdAt: Date? { get }
-
The updated date of the conversation.
Declaration
Swift
public var updatedAt: Date? { get }
-
The attributes of the conversation.
Declaration
Swift
public var attributes: [String : Any]? { get }
-
The members of the conversation.
Declaration
Swift
public var members: [String]? { get }
-
Whether the offline notification of this conversation has been muted by the client.
Declaration
Swift
public var isMuted: Bool { get }
-
Raw data of the conversation.
Declaration
Swift
public private(set) var rawData: RawData { get set }
-
Get value via subscript syntax.
Declaration
Swift
public subscript(key: String) -> Any? { get }
-
Indicates whether the data of conversation is outdated, after refresh, this property will be false.
Declaration
Swift
public internal(set) var isOutdated: Bool { get set }
-
The last message of the conversation.
Declaration
Swift
public private(set) var lastMessage: IMMessage? { get set }
-
The last delivered date of message
Declaration
Swift
public var lastDeliveredAt: Date? { get }
-
The last delivered timestamp of message
Declaration
Swift
public internal(set) var lastDeliveredTimestamp: Int64? { get set }
-
The last read date of message
Declaration
Swift
public var lastReadAt: Date? { get }
-
The last read timestamp of message
Declaration
Swift
public internal(set) var lastReadTimestamp: Int64? { get set }
-
The unread message count of the conversation
Declaration
Swift
public internal(set) var unreadMessageCount: Int { get set }
-
Indicates whether has unread message mentioning the client.
Declaration
Swift
public var isUnreadMessageContainMention: Bool { get set }
-
The table of member infomation.
Declaration
Swift
public var memberInfoTable: [String : MemberInfo]? { get }
-
Clear unread messages that its sent timestamp less than the sent timestamp of the parameter message.
Declaration
Swift
public func read(message: IMMessage? = nil)
Parameters
message
The default is the last message.
-
Get the last message receipt timestamps in this conversation. if the timestamps have been updated, then properties of this conversation, lastReadAt and lastDeliveredAt, will be updated. after lastReadAt or lastDeliveredAt has been updated, the client will dispatch relative events, @see
IMConversationEvent
.Declaration
Swift
public func getMessageReceiptFlag(completion: @escaping (LCGenericResult<MessageReceiptFlag>) -> Void) throws
Parameters
completion
Result callback.
-
Fetch the last message receipt timestamps in this conversation. if the timestamps have been updated, then properties of this conversation, lastReadAt and lastDeliveredAt, will be updated. after lastReadAt or lastDeliveredAt has been updated, the client will dispatch relative events, @see
IMConversationEvent
.Declaration
Swift
public func fetchReceiptTimestamps() throws
-
Join in this conversation.
Declaration
Swift
public func join(completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
completion
callback.
-
Leave this conversation.
Declaration
Swift
public func leave(completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
completion
callback.
-
Add members to this conversation.
Declaration
Swift
public func add(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The set of member’s ID.
completion
callback.
-
Remove members from this conversation.
Declaration
Swift
public func remove(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The set of member’s ID.
completion
callback.
-
Get count of members in this conversation. if it’s chat-room, the success result means count of online-members.
Declaration
Swift
public func countMembers(completion: @escaping (LCCountResult) -> Void)
Parameters
completion
Result callback.
-
Check whether client joined this conversation.
Declaration
Swift
public func checkJoined(completion: @escaping (LCGenericResult<Bool>) -> Void)
Parameters
completion
Result callback.
-
Mute this conversation.
Declaration
Swift
public func mute(completion: @escaping (LCBooleanResult) -> Void)
Parameters
completion
callback.
-
Unmute this conversation.
Declaration
Swift
public func unmute(completion: @escaping (LCBooleanResult) -> Void)
Parameters
completion
callback.
-
Refresh conversation’s data.
Declaration
Swift
public func refresh(completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
completion
callback
-
Update conversation’s data.
Declaration
Swift
public func update(attribution data: [String : Any], completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
data
The data to be updated.
completion
callback.
-
Fetching the table of member infomation in this conversation. The result will be cached in the property
memberInfoTable
.Declaration
Swift
public func fetchMemberInfoTable( limit: Int = 500, offset: Int? = nil, completion: @escaping (LCBooleanResult) -> Void)
Parameters
limit
The max number of results, default is
500
.offset
The number of objects to skip.
completion
Result of callback.
-
Get infomation of one member in the conversation.
Declaration
Swift
public func getMemberInfo(by memberID: String, completion: @escaping (LCGenericResult<MemberInfo?>) -> Void)
Parameters
memberID
The ID of the member.
completion
Result of callback.
-
Updating role of the member in the conversaiton.
Throws
If role parameter is owner, throw error.Declaration
Swift
public func update( role: MemberRole, ofMember memberID: String, completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
role
The role will be updated.
memberID
The ID of the member who will be updated.
completion
Result of callback.
-
Blocking members in the conversation.
Throws
When parametermembers
is empty.Declaration
Swift
public func block(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The members will be blocked.
completion
Result of callback.
-
Unblocking members in the conversation.
Throws
When parametermembers
is empty.Declaration
Swift
public func unblock(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The members will be unblocked.
completion
Result of callback.
-
Get the blocked members in the conversation.
Throws
When limit out of range.Declaration
Swift
public func getBlockedMembers( limit: Int = 50, next: String? = nil, completion: @escaping (LCGenericResult<BlockedMembersResult>) -> Void) throws
Parameters
limit
Count limit.
next
Offset.
completion
Result of callback.
-
Check if one member has been blocked in the conversation.
Declaration
Swift
public func checkBlocking( member ID: String, completion: @escaping (LCGenericResult<Bool>) -> Void)
Parameters
ID
The ID of member.
completion
Result of callback.
-
Muting members in the conversation.
Throws
When parametermembers
is empty.Declaration
Swift
public func mute(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The members will be muted.
completion
Result of callback.
-
Unmuting members in the conversation.
Throws
When parametermembers
is empty.Declaration
Swift
public func unmute(members: Set<String>, completion: @escaping (MemberResult) -> Void) throws
Parameters
members
The members will be unmuted.
completion
Result of callback.
-
Get the muted members in the conversation.
Throws
When parameterlimit
out of range.Declaration
Swift
public func getMutedMembers( limit: Int = 50, next: String? = nil, completion: @escaping (LCGenericResult<MutedMembersResult>) -> Void) throws
Parameters
limit
Count limit.
next
Offset.
completion
Result of callback.
-
Check if one member has been muted in the conversation.
Declaration
Swift
public func checkMuting( member ID: String, completion: @escaping (LCGenericResult<Bool>) -> Void)
Parameters
ID
The ID of member.
completion
Result of callback.
-
Undocumented
Declaration
Swift
public func insertFailedMessageToCache( _ message: IMMessage, completion: @escaping (LCBooleanResult) -> Void) throws
-
Undocumented
Declaration
Swift
public func removeFailedMessageFromCache( _ message: IMMessage, completion: @escaping (LCBooleanResult) -> Void) throws
-
Message Sending Option
See moreDeclaration
Swift
public struct MessageSendOptions : OptionSet
-
Send Message.
Declaration
Swift
public func send( message: IMMessage, options: MessageSendOptions = .default, priority: IMChatRoom.MessagePriority? = nil, pushData: [String: Any]? = nil, progressQueue: DispatchQueue = .main, progress: ((Double) -> Void)? = nil, completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
message
The message to be sent. Properties such as
ID
andsentTimeStamp
are updated.options
@see
MessageSendOptions
.priority
pushData
The push data of APNs.
progressQueue
The queue where the progress be called. default is main.
progress
The file uploading progress.
completion
callback.
-
Update the content of a sent message.
Declaration
Swift
public func update( oldMessage: IMMessage, to newMessage: IMMessage, progressQueue: DispatchQueue = .main, progress: ((Double) -> Void)? = nil, completion: @escaping (LCBooleanResult) -> Void) throws
Parameters
oldMessage
The sent message to be updated.
newMessage
The message which has new content.
progressQueue
The queue where the progress be called, default is main.
progress
The file uploading progress.
completion
Result callback.
-
Recall a sent message.
Declaration
Swift
public func recall( message: IMMessage, completion: @escaping (LCGenericResult<IMRecalledMessage>) -> Void) throws
Parameters
message
The message has been sent.
completion
Result callback.
-
The timestamp flag of message receipt.
See moreDeclaration
Swift
public struct MessageReceiptFlag
-
The limit of the messge query result.
Declaration
Swift
public static let limitRangeOfMessageQuery: ClosedRange<Int>
-
The endpoint of the message queue.
See moreDeclaration
Swift
public struct MessageQueryEndpoint
-
The query direction.
See moreDeclaration
Swift
public enum MessageQueryDirection : Int
-
Policy of Message Query
default
: If using local storage, it iscacheThenNetwork
. If not using local storage, it isonlyNetwork
.- onlyNetwork: Only query remote server
- onlyCache: Only query local storage
- cacheThenNetwork: Query local storage firstly, if not get result, then query remote server.
Declaration
Swift
public enum MessageQueryPolicy
-
Message Query.
Declaration
Swift
public func queryMessage( start: MessageQueryEndpoint? = nil, end: MessageQueryEndpoint? = nil, direction: MessageQueryDirection? = nil, limit: Int = 20, type: IMMessageCategorizing.MessageType? = nil, policy: MessageQueryPolicy = .default, completion: @escaping (LCGenericResult<[IMMessage]>) -> Void) throws
Parameters
start
start endpoint, @see
MessageQueryEndpoint
.end
end endpoint, @see
MessageQueryEndpoint
.direction
@see
MessageQueryDirection
. default isMessageQueryDirection.newToOld
.limit
The limit of the query result, should in range
limitRangeOfMessageQuery
. default is 20.type
@see
IMMessageCategorizing.MessageType
. if this parameter did set,policy
will always be.onlyNetwork
.policy
@see
IMConversation.MessageQueryPolicy
. ifclient.options
contains.usingLocalStorage
, then default is.cacheThenNetwork
, else default is.onlyNetwork
.completion
callback.
-
Result for member operation.
- allSucceeded: Operation for all members are succeeded.
- failure: Operation failed.
- slicing: Operation for part members are succeeded, and for part members are failed.
Declaration
Swift
public enum MemberResult : LCResultType
-
Role of the member in the conversation. Privilege: owner > manager > member.
- owner: Who owns the conversation.
- manager: Who can manage the conversation.
- member: General member.
Declaration
Swift
public enum MemberRole : String
-
The infomation of one member in the conversation.
See moreDeclaration
Swift
public struct MemberInfo
-
Undocumented
Declaration
Swift
public typealias BlockedMembersResult = (members: [String], next: String?)
-
Undocumented
Declaration
Swift
public typealias MutedMembersResult = (members: [String], next: String?)