ContentType 枚举(HarmonyOS IMLib)

消息内容类型枚举:共 9 个取值,定义来自 domain.json → enums.ContentType。

契约预留平台

HarmonyOS 当前为契约预留:本页的类、方法签名、枚举与示例全部来自冻结 IDL 与 sdk-bindings.json,SDK 尚未交付;实现后签名不会变化。

基本信息​

项值
枚举ContentType
取值数9
本平台常量名ContentType
IDL 来源domain.json → enums.ContentType
跨端一致性取值跨端一致;常量名与成员名按平台绑定
平台状态契约预留

枚举常量摘要​

取值序号说明
text0文本消息
image1图片消息
file2文件消息
voice3语音消息
location4位置消息
custom5自定义消息(data 任意 JSON 透传)
recall6撤回占位消息(服务端生成,客户端只读)
system7系统通知消息
combine8—

使用说明​

MessageContent.type 的取值;发送时按 type 校验必填字段,未知类型按 custom 透传。

示例​

TypeScript
const value: ContentType = ContentType.text;

相关链接​