getOneConversation
Description
info
Get conversation information. Specify groupID for group chat, specify counterparty's userID for one-to-one chat.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<ConversationInfo> getOneConversation({
required String sourceID,
required int sessionType,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sessionType | int | Yes | Session type |
| sourceID | String | Yes | User ID for one-to-one chat, group ID for group chat |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | ConversationInfo | Success return |
Code Example
final conversationInfo = await OpenIM.iMManager.conversationManager.getOneConversation(sourceID: sourceID, sessionType: sessionType);
//todo
Function Prototype
- (void)getOneConversationWithSessionType:(OIMConversationType)sessionType
sourceID:(NSString *)sourceID
onSuccess:(nullable OIMConversationInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sessionType | OIMConversationType | Yes | Session type |
| sourceID | NSString | Yes | User ID for one-to-one chat, group ID for group chat |
Return Result
| Name | Type | Description |
|---|---|---|
| onSuccess | OIMConversationInfo | Success return |
| onFailure | OIMFailureCallback | Failure return |
Code Example
[OIMManager.manager getOneConversationWithSessionType:
sourceID:@""
onSuccess:^(OIMConversationInfo * _Nullable conversation) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getOneConversation(OnBase<ConversationInfo> base, String sourceId, int sessionType)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| base | OnBase<ConversationInfo> | Yes | Callback interface |
| sessionType | int | Yes | Session type ConversationType |
| sourceID | String | Yes | User ID for one-to-one chat, group ID for group chat |
Code Example
OpenIMClient.getInstance().conversationManager.getOneConversation(new OnBase<List<ConversationInfo>>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(List<ConversationInfo> data) {
}
},sessionType,sourceID);
Function Prototype
IMSDK.getOneConversation({
sourceID: string;
sessionType: SessionType;
},operationID?: string): Promise<WsResponse<ConversationItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sourceID | string | Yes | User ID for one-to-one chat(user ID), or groupID(group ID) |
| sessionType | SessionType | Yes | Session type |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<ConversationItem>> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.getOneConversation({
sourceID: 'user1',
sessionType: 1,
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('getOneConversation', operationID: string, {
sourceID: string;
sessionType: SessionType;
}): Promise<ConversationItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| sourceID | string | Yes | User ID for one-to-one chat(user ID), or groupID(group ID) |
| sessionType | SessionType | Yes | Session type |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<ConversationItem> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getOneConversation', IMSDK.uuid(), {
sourceID: 'user1',
sessionType: 1,
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.getOneConversation({
sessionType: number,
sourceID: string,
}, operationID?: string): Promise<ConversationItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sourceID | string | Yes | User ID for one-to-one chat, or groupID for group chat |
| sessionType | SessionType | Yes | Session type |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<ConversationItem> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.getOneConversation({
sourceID: 'user1',
sessionType: 1,
})
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static void GetOneConversation(OnBase<Conversation> cb, ConversationType sessionType, string sourceId)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| cb | OnBase<Conversation> | Yes | Callback interface |
| sessionType | ConversationType | Yes | Session type |
| sourceId | string | Yes | User ID for one-to-one chat, group ID for group chat |
Code Example
IMSDK.GetOneConversation((list,errCode,errMsg)=>{
},sessionType,sourceID);