SDKsAndroid
生成会话 ID
使用 getConversationIDBySessionType() 按聊天目标计算 Android 会话 ID。
只需要会话 ID 时,调用 getConversationIDBySessionType(),不要在应用层自行拼接。
String conversationID = OpenIMClient.getInstance().conversationManager
.getConversationIDBySessionType(
targetUserID,
ConversationType.SINGLE_CHAT
);sourceId 在单聊中是对方 userID,在群聊中是 groupID。群聊根据群类型使用 ConversationType.GROUP_CHAT 或 ConversationType.SUPER_GROUP_CHAT。
该方法同步返回 String 类型的 conversationID,不返回完整 ConversationInfo,也不触发会话 listener。需要会话资料时调用查询指定会话。
这个页面有帮助吗?