# 会话

# 获取会话信息

# 使用说明

此 api 设计上是用来选择临时会话的,但是目前 yach 没有临时会话的概念,所以目前和根据 corpid 选择会话功能一致,建议用其代替

Android iOS PC 是否需要鉴权
支持 支持 不支持 需要
// 全量引入调用方式
yy.biz.chat.pickConversation({
  isConfirm: true, //是否弹确认框
  multiple: true, // 是否支持多选,默认false
  limitTips: "超出了", //超过限定会话提示
  maxConversations: 100, //最大选择会话数量
  onSuccess: function () {
    //onSuccess将在选择结束之后调用
    /*[{
        cid: 'xxxx',
        title:'xxx',
        type:0,
      },{
        cid: 'xxxx',
        title:'xxx',
        type:1,
      }]*/
  },
  onFail: function () {}
});

// 按需加载调用方式,参数与全量引入相同
pickConversation({...});

# 参数说明

参数 参数类型 说明
isConfirm Boolean 是否弹出确认窗口,默认为 true
multiple Boolean 是否支持多选,默认单选
limitTips String 超过限定会话提示
maxConversations Number 最大选择会话数量

# 返回说明

返回一个数组,数组内包裹对象

参数 说明
cid 会话 id
title 会话标题
type 会话类型(单聊:0;群聊:1)

# 调试

biz.chat.pickConversation

# 根据 corpid 选择会话

# 使用说明

Android iOS PC 是否需要鉴权
支持 支持 支持 v3.1.0 增加disabledUsers disabledTeams 字段 需要
// 全量引入调用方式
yy.biz.chat.chooseConversationByCorpId({
  isAllowCreateGroup: false,
  filterNotOwnerGroup: false,
  multiple: true, // 是否支持多选,默认false
  limitTips: "超出了", //超过限定会话提示
  maxConversations: 100, //最大选择会话数量
  disabledUsers:[], // 禁用选择单聊
  disabledTeams:[], // 禁用选择群聊
  onSuccess: function () {
    //onSuccess将在选择结束之后调用
    /*[{
            chatId: 'xxxx',
            title:'xxx',
            type:0,
        },{
            chatId: 'xxxx',
            title:'xxx',
            type:0,
        }]*/
  },
  onFail: function () {}
});

// 按需加载调用方式,参数与全量引入相同
chooseConversationByCorpId({...});

# 参数说明

参数 参数类型 说明
multiple Boolean 是否支持多选,默认单选
limitTips String 超过限定会话提示
maxConversations Number 最大选择会话数量
isAllowCreateGroup Boolean 是否允许创建会话,Android、ios 支持
filterNotOwnerGroup Boolean 是否限制为自己创建的会话,Android 支持
disabledUsers Array[string、number] 禁用选择单聊
disabledTeams Array[string、number] 禁用选择群聊
disabledDepartments Array[string、number] 禁用选择群聊,pc 支持
pickedUsers Array[string、number] 已选单聊,pc 支持
pickedTeams Array[string、number] 已选群聊,pc 支持
pickedDepartments Array[string、number] 已选部门,pc 支持
requiredUsers Array[string、number] 必须选择的单聊,pc 支持
requiredTeams Array[string、number] 必须选择的群聊,pc 支持
requiredDepartments Array[string、number] 必须选择的部门,pc 支持
showPartner Boolean 是否展示我的伙伴入口,默认为 false,仅 pc 端支持

# 返回说明

返回一个数组,数组内包裹对象

参数 说明
chatId 会话 id
title 会话标题
type 会话类型(单聊:0;群聊:1)

# 调试

biz.chat.chooseConversationByCorpId

# 打开与某个用户的单聊会话 v3.1.0 可以支持定位消息,需要传msgId

# 使用说明

Android iOS PC 是否需要鉴权
支持 支持 支持 需要
// 全量引入调用方式
yy.biz.chat.openSingleChat({
  userId: "xxx", // 用户的工号
  msgId: 'xxxx', // 传msgId支持定位
  time: 'xxxxx', // 时间戳
  isRobotUser: false, // 是否为机器人,默认 false
  onSuccess: function () {},
  onFail: function () {}
});

// 按需加载调用方式,参数与全量引入相同
openSingleChat({...});

# 参数说明

参数 参数类型 必传 说明
userId String
用户外部 ID
msgId String
消息id
time String
时间戳
isRobotUser boolean
是否为机器人,默认 false

# 返回说明

# 调试

biz.chat.openSingleChat

# 打开某个群聊会话 v3.1.0

# 使用说明

Android iOS PC 是否需要鉴权
支持 支持 支持 需要
// 全量引入调用方式
yy.biz.chat.openTeamChat({
  teamId: "xxx", // 群ID
  msgId:'xxxx',  // 消息id,传这个可以支持定位消息
  time:'xxxx', // PC
  onSuccess: function () {},
  onFail: function () {}
});

// 按需加载调用方式,参数与全量引入相同
openTeamChat({...});

# 参数说明

参数 参数类型 必传 说明
teamId String
群id
msgId String
消息id
time String
时间戳

# 返回说明

# 调试

biz.chat.openTeamChat

# 打开小组会话

# 使用说明

Android iOS PC 是否需要鉴权
支持 支持 不支持 需要
// 全量引入调用方式
yy.biz.chat.openSquad({
  sessionId: "xxx", // 小组ID
  onSuccess: function () {},
  onFail: function () {}
});

// 按需加载调用方式,参数与全量引入相同
openTeamChat({...});

# 参数说明

参数 参数类型 必传 说明
sessionId String
小组ID

# 返回说明

# 调试

biz.chat.openSquad

# 发送私聊会话

# 使用说明

Android iOS PC 是否需要鉴权
支持 支持 支持 需要
// 全量引入调用方式
yy.biz.chat.sendP2PMsg({
  toUserId: "yachxxx", // 接收人的用户 YachID
  message: "xxx", // 消息体
  onSuccess: function () {},
  onFail: function () {}
});



// 按需加载调用方式,参数与全量引入相同
sendP2PMsg({...});

# 参数说明

参数 参数类型 必传 说明
toUserId String
接收人的用户 YachID
message String
消息体

message消息体参考地址

# 返回说明

发送结果 { "code": 200, "msg": "", "obj": { "yachMid":"61087906893637191" } }

# 调试

biz.chat.sendP2PMsg
上次更新: 12/4/2023, 11:04:38 AM
foo