getConversationIDBySessionType
Description
info
Get the conversation ID based on the session type.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron
- React-Native
- Unity
Function Prototype
Future<dynamic> getConversationIDBySessionType({
required String sourceID,
required int sessionType,
})
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 |
|---|---|---|
| ~ | String | Success return |
Code Example
final conversationID = await OpenIM.iMManager.conversationManager.getConversationIDBySessionType(sourceID: sourceID, sessionType: sessionType);
//todo
Function Prototype
- (NSString *)getConversationIDBySessionType:(OIMConversationType)sessionType
sourceID:(NSString *)sourceID;
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 |
|---|---|---|
| conversationID | NSString | Success return |
Code Example
NSString *conversationID = [OIMManager.manager getConversationIDBySessionType:OIMConversationTypeC2C sourceID:@""];
Function Prototype
public String getConversationIDBySessionType(String sourceId, int sessionType)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sessionType | OIMConversationType | Yes | Session type |
| sourceID | String | Yes | User ID for one-to-one chat, group ID for group chat |
Return Result
| Name | Type | Description |
|---|---|---|
| conversationID | String | Success return |
Code Example
String conversationID=OpenIMClient.getInstance().conversationManager.getConversationIDBySessionType(sourceID,sessionType)
Function Prototype
IMSDK.getConversationIDBySessionType({
sourceID: string;
sessionType: SessionType;
},operationID?: string): Promise<WsResponse<string>>
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 |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<string>> | 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();
IMSDK.getConversationIDBySessionType({
sourceID: 'user1',
sessionType: 1,
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('getConversationIDBySessionType', operationID: string, {
sourceID: string;
sessionType: SessionType;
}): Promise<string>
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, or groupID for group chat |
| 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<string> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getConversationIDBySessionType', IMSDK.uuid(), {
sourceID: 'user1',
sessionType: 1,
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.getConversationIDBySessionType({
sourceID: string,
sessionType: number,
}, operationID?: string): Promise<string>
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<string> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.getConversationIDBySessionType({
sourceID: 'user1',
sessionType: 1,
}
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static string GetConversationIdBySessionType(string sourceId, int sessionType)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| sourceId | string | Yes | User ID for one-to-one chat, group ID for group chat |
| sessionType | ConversationType | Yes | Session type |
Return Result
| Name | Type | Description |
|---|---|---|
| conversationId | string | Success return |
Code Example
var conversationID =IMSDK.GetConversationIDBySessionType(sourceID,sessionType);