TextMessage

new TextMessage(textopt)

文类类型消息
Parameters:
Name Type Attributes Default Description
text String <optional>
''
Throws:
text 不是 String 类型
Type
TypeError

Extends

Members

static, constant TYPE :Number

attributes :Object

Inherited From:

nullable cid :String

消息所在的 conversation id
Inherited From:

nullable deliveredAt :Date

消息送达时间
Inherited From:

from :String

消息发送者
Inherited From:

id :String

Inherited From:

readonly mentioned :Boolean

当前用户是否在该消息中被提及
Since:
  • 4.0.0
Inherited From:

mentionedAll :Boolean

消息是否提及了所有人
Since:
  • 4.0.0
Inherited From:

mentionList :Array.<String>

消息提及的用户
Since:
  • 4.0.0
Inherited From:

readonly status :Symbol

消息状态,值为 module:leancloud-realtime.MessageStatus 之一
Since:
  • 3.2.0
Inherited From:

readonly summary :String

在客户端需要以文本形式展示该消息时显示的文案, 如 [红包] 新春快乐。 默认值为消息的 text。
Inherited From:

text :String

Inherited From:

timestamp :Date

消息发送时间
Inherited From:

readonly type :Number

Inherited From:

updatedAt :Date

消息修改或撤回时间,可以通过比较其与消息的 timestamp 是否相等判断消息是否被修改过或撤回过。
Since:
  • 3.5.0
Inherited From:

Methods

getAttributes() → {Object}

Returns:
Object
Inherited From:

getMentionList() → {Array.<String>}

获取提及用户列表
Returns:
Array.<String> - 提及用户的 id 列表
Since:
  • 4.0.0
Inherited From:

getText() → {String}

Returns:
String
Inherited From:

mentionAll(valueopt) → {this}

设置是否提及所有人
Parameters:
Name Type Attributes Default Description
value Boolean <optional>
true
Returns:
this - self
Since:
  • 4.0.0
Inherited From:

setAttributes(attributes) → {this}

Parameters:
Name Type Description
attributes Object
Returns:
this - self
Inherited From:

setMentionList(clients) → {this}

设置提及用户列表
Parameters:
Name Type Description
clients Array.<String> 提及用户的 id 列表
Returns:
this - self
Since:
  • 4.0.0
Inherited From:

setText(text) → {this}

Parameters:
Name Type Description
text String
Returns:
this - self
Inherited From:

toFullJSON() → {Object}

返回 JSON 格式的消息,与 toJSON 不同的是,该对象包含了完整的信息,可以通过 IMClient#parseMessage 反序列化。
Returns:
Object - 返回值是一个 plain Object
Since:
  • 4.0.0
Inherited From:

toJSON() → {Object}

返回 JSON 格式的消息
Returns:
Object - 返回值是一个 plain Object
Inherited From: