getOneConversation
Feature Introduction
Description
Retrieve conversation details.
- 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 | Mandatory | Description |
---|---|---|---|
sessionType | int | Yes | Type of conversation |
sourceID | String | Yes | User ID for private chats, Group ID for group chats |
Return Value
Name | Type | Description |
---|---|---|
~ | ConversationInfo | Successful return |
Example Code
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 | Mandatory | Description |
---|---|---|---|
sessionType | OIMConversationType | Yes | Type of conversation |
sourceID | NSString | Yes | User ID for private chats, Group ID for group chats |
Return Value
Name | Type | Description |
---|---|---|
onSuccess | OIMConversationInfo | Successful return |
onFailure | OIMFailureCallback | Failed return |
Example Code
[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 | Mandatory | Description |
---|---|---|---|
base | OnBase<List<ConversationInfo>> | Yes | Callback interface |
sessionType | int | Yes | Type of conversation ConversationType |
sourceID | String | Yes | User ID for private chats, Group ID for group chats |
Example Code
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 | Mandatory | Description |
---|---|---|---|
sourceID | string | Yes | User ID for private chats or groupID for group chats |
sessionType | SessionType | Yes | Type of conversation |
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<ConversationItem>> | Successful callback |
Promise.catch() | Promise<WsResponse>> | Failed callback |
Example Code
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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.getOneConversation({
sourceID: 'user1',
sessionType: 1,
})
.then(({ data }) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
Function Prototype
IMSDK.asyncApi('getOneConversation', operationID: string, {
sourceID: string;
sessionType: SessionType;
}): Promise<ConversationItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID for troubleshooting, recommended to use current time and random number |
sourceID | string | Yes | User ID for private chats or groupID for group chats |
sessionType | SessionType | Yes | Type of conversation |
Return Value
Through
openim-uniapp-polyfill
package, the function is promisified. When calling, usethen
andcatch
to handle successful and failed callbacks respectively.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<ConversationItem> | Successful callback |
Promise.catch() | Promise<CatchResponse>> | Failed callback |
Example Code
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getOneConversation', IMSDK.uuid(), {
sourceID: 'user1',
sessionType: 1,
})
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
Function Prototype
OpenIMSDKRN.getOneConversation({
sessionType: number,
sourceID: string,
}, operationID: string): Promise<ConversationItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
sourceID | string | Yes | User ID for private chats or groupID for group chats |
sessionType | SessionType | Yes | Conversation type |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<ConversationItem> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getOneConversation({
sourceID: 'user1',
sessionType: 1,
}, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
Function Prototype
public static void GetOneConversation(OnBase<Conversation> cb, ConversationType sessionType, string sourceId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<Conversation> | Yes | Callback |
sessionType | int | Yes | Conversation TypeConversationType |
sourceID | string | Yes | User ID for private chats or groupID for group chats |
Code Example
IMSDK.GetOneConversation((list,errCode,errMsg)=>{
},sessionType,sourceID);