insertGroupMessageToLocalStorage
Feature Introduction
Description
Insert a group chat message locally.
Note
Visible only on the current device. Related Callback: onConversationChanged
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> insertGroupMessageToLocalStorage({
String? groupID,
String? senderID,
Message? message,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | Message | Yes | Message body |
groupID | String | Yes | groupID receiving the message |
senderID | String | Yes | userID sending the message |
Return Result
Name | Type | Description |
---|---|---|
~ | Message | Successful return |
Code Example
await OpenIM.iMManager.messageManager.insertGroupMessageToLocalStorage(
groupID: '',
senderID: '',
message: Message()
);
// todo
Function Prototype
- (void)insertGroupMessageToLocalStorage:(OIMMessageInfo *)message
groupID:(NSString * _Nullable)groupID
sendID:(NSString * _Nullable)sendID
onSuccess:(nullable OIMMessageInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | OIMMessageInfo | Yes | Message body |
groupID | NSString | Yes | groupID receiving the message |
sendID | NSString | Yes | userID sending the message |
Return Result
Name | Type | Description |
---|---|---|
onSuccess | OIMMessageInfo | Successful return |
onFailure | OIMFailureCallback | Failed return |
Code Example
[OIMManager.manager insertGroupMessageToLocalStorage:
groupID:@""
sendID:@""
onSuccess:^(OIMMessageInfo * _Nullable message) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void insertGroupMessageToLocalStorage(OnBase<String> base, Message message, String groupID, String senderID)
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
callBack | OnBase<String> | Yes | Callback interface |
message | Message | Yes | Message body |
groupID | String | Yes | groupID receiving the message |
senderID | String | Yes | userID sending the message |
Code Example
OpenIMClient.getInstance().messageManager.insertGroupMessageToLocalStorage(new OnBase<AdvancedMessage>() {
public void onError(int code, String error) {
}
public void onSuccess(AdvancedMessage data) {
}
}, message, groupID, senderID);
Function Prototype
IMSDK.insertGroupMessageToLocalStorage({
message: MessageItem;
groupID: string;
sendID: string;
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | MessageItem | Yes | Message body |
groupID | string | Yes | groupID receiving the message |
sendID | string | Yes | userID sending the message |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | 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 { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.insertGroupMessageToLocalStorage({
message: {
// MessageItem
...
};
groupID: "",
sendID: "",
})
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('insertGroupMessageToLocalStorage', operationID: string,{
message: MessageItem;
groupID: string;
sendID: string;
}): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for troubleshooting, keep unique. Recommended to use current time and random number |
message | MessageItem | Yes | Message body |
groupID | string | Yes | groupID receiving the message |
sendID | string | Yes | userID sending the message |
Return Result
Using the
openim-uniapp-polyfill
package, the function is Promise-based. Usethen
andcatch
to determine and handle successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failed callback |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi(
'insertGroupMessageToLocalStorage',
IMSDK.uuid(),
{
message: {
// MessageItem
...
},
groupID: "",
sendID: "",
}
)
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDKRN.insertGroupMessageToLocalStorage({
message: MessageItem;
groupID: string;
sendID: string;
},operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for troubleshooting, keep unique. Recommended to use current time and random number |
message | MessageItem | Yes | Message body |
groupID | string | Yes | groupID receiving the message |
sendID | string | Yes | userID sending the message |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.insertGroupMessageToLocalStorage({
message: {
// MessageItem
...
};
groupID: "",
sendID: "",
}, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
public static void InsertGroupMessageToLocalStorage(OnBase<Message> cb, Message message, string groupId, string sendId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<Message> | Yes | Callback |
message | Message | Yes | Message body |
groupId | string | Yes | groupID receiving the message |
senderId | string | Yes | userID sending the message |
Code Example
IMSDK.InsertGroupMessageToLocalStorage((msg,errCode,errMsg)=>{
}, message, groupId, senderId);