new TextMessage(textopt)
- Source:
文类类型消息
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
String |
<optional> |
''
|
Throws:
-
text 不是 String 类型
- Type
- TypeError
Extends
Members
(static, constant) TYPE :Number
- Source:
Type:
- Number
attributes :Object
- Source:
- Inherited From:
Type:
- Object
(nullable) cid :String
- Source:
- Inherited From:
消息所在的 conversation id
Type:
- String
(nullable) deliveredAt :Date
- Source:
- Inherited From:
消息送达时间
Type:
- Date
from :String
- Source:
- Inherited From:
消息发送者
Type:
- String
id :String
- Source:
- Inherited From:
Type:
- String
needReceipt :Boolean
- Source:
- Inherited From:
- Deprecated:
- 指定是否需要送达回执请使用 Conversation#send 方法的 `options.receipt` 参数。
标记需要回执
Type:
- Boolean
(readonly) status :Symbol
- Source:
- Since:
- 3.2.0
- Inherited From:
消息状态,值为 module:leancloud-realtime.MessageStatus 之一
Type:
- Symbol
(readonly) summary :String
- Source:
- Inherited From:
在客户端需要以文本形式展示该消息时显示的文案,
如
[红包] 新春快乐
。
默认值为消息的 text。
Type:
- String
text :String
- Source:
- Inherited From:
Type:
- String
timestamp :Date
- Source:
- Inherited From:
消息发送时间
Type:
- Date
transient :Boolean
- Source:
- Inherited From:
- Deprecated:
- 指定是否作为暂态消息发送请使用 Conversation#send 方法的 `options.transient` 参数。 请不要将是否为暂态作为区分某些消息的标记,请使用富媒体消息的属性(attributes)或使用自定义消息类型。 该字段将在 v4.0 中移除。
标记暂态消息
Type:
- Boolean
(readonly) type :Number
- Source:
- Inherited From:
Type:
- Number
updatedAt :Date
- Source:
- Since:
- 3.5.0
- Inherited From:
消息修改或撤回时间,可以通过比较其与消息的 timestamp 是否相等判断消息是否被修改过或撤回过。
Type:
- Date
Methods
getAttributes() → {Object}
- Source:
- Inherited From:
Returns:
- Type
- Object
getText() → {String}
- Source:
- Inherited From:
Returns:
- Type
- String
setAttributes(attributes) → {TypedMessage}
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object |
Returns:
self
- Type
- TypedMessage
setNeedReceipt(needReceipt) → {Message}
- Source:
- Inherited From:
- Deprecated:
- 请使用 Conversation#send 方法的 `options.receipt` 选项代替。
设置是否需要送达回执
Parameters:
Name | Type | Description |
---|---|---|
needReceipt |
Boolean |
Returns:
self
- Type
- Message
setText(text) → {TypedMessage}
- Source:
- Inherited From:
Parameters:
Name | Type | Description |
---|---|---|
text |
String |
Returns:
self
- Type
- TypedMessage
setTransient(transient) → {Message}
- Source:
- Inherited From:
- Deprecated:
- 请使用 Conversation#send 方法的 `options.transient` 选项代替。
设置是否是暂态消息
Parameters:
Name | Type | Description |
---|---|---|
transient |
Boolean |
Returns:
self
- Type
- Message
(protected) toJSON() → {Object}
- Source:
- Inherited From:
- Implements:
将当前消息序列化为 JSON 对象
Returns:
- Type
- Object