getConversationIDBySessionType
Feature Introduction
Description
Get the conversation ID based on the session type.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> getConversationIDBySessionType({
required String sourceID,
required int sessionType,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
sessionType | int | Yes | Session type |
sourceID | String | Yes | User ID for individual chat, group ID for group chat |
Return Value
Name | Type | Description |
---|---|---|
~ | String | Successful 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 | Mandatory | Description |
---|---|---|---|
sessionType | OIMConversationType | Yes | Session type |
sourceID | NSString | Yes | User ID for individual chat, group ID for group chat |
Return Value
Name | Type | Description |
---|---|---|
conversationID | NSString | Successful 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 | Mandatory | Description |
---|---|---|---|
sessionType | OIMConversationType | Yes | Session type |
sourceID | String | Yes | User ID for individual chat, group ID for group chat |
Return Value
Name | Type | Description |
---|---|---|
conversationID | String | Successful 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 | Mandatory | Description |
---|---|---|---|
sourceID | string | Yes | User ID for individual chat, or groupID for group chat |
sessionType | SessionType | Yes | Session type |
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<string>> | Successful callback |
Promise.catch() | Promise<WsResponse> | Failed 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 { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.getConversationIDBySessionType({
sourceID: 'user1',
sessionType: 1,
})
.then(({ data }) => {
// Successful
})
.catch(({ errCode, errMsg }) => {
// Failed
});
Function Prototype
IMSDK.asyncApi('getConversationIDBySessionType', operationID: string, {
sourceID: string;
sessionType: SessionType;
}): Promise<string>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID for issue tracking, unique, recommended current time combined with random number |
sourceID | string | Yes | User ID for individual chat, or groupID for group chat |
sessionType | SessionType | Yes | Session type |
Return Results
The function is made Promise-based through the
openim-uniapp-polyfill
package. When calling, you need to usethen
andcatch
to judge and handle successful and failed callbacks respectively.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<string> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failed callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getConversationIDBySessionType', IMSDK.uuid(), {
sourceID: 'user1',
sessionType: 1,
})
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.getConversationIDBySessionType({
sourceID: string,
sessionType: number,
}, operationID: string): Promise<string>
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's ID(private chat)or groupID(group chat) |
sessionType | SessionType | Yes | Conversation Type |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<string> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getConversationIDBySessionType({
sourceID: 'user1',
sessionType: 1,
}, 'operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static string GetConversationIdBySessionType(string sourceId, int sessionType)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
sourceId | string | Yes | User's ID(private chat)or groupID(group chat) |
sessionType | OIMConversationType | Yes | Conversation Type |
Return Result
Name | Type | Description |
---|---|---|
conversationId | string | Message Struct |
Code Example
var conversationId =IMSDK.GetConversationIDBySessionType(sourceId,sessionType);