insertSingleMessageToLocalStorage
Feature Introduction
Description
Inserts a single 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> insertSingleMessageToLocalStorage({
String? receiverID,
String? senderID,
Message? message,
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | Message | Yes | Message body |
receiverID | String | Yes | User ID receiving the message |
senderID | String | Yes | User ID sending the message |
Return Results
Name | Type | Description |
---|---|---|
~ | Message | Successful return |
Code Example
await OpenIM.iMManager.messageManager.insertSingleMessageToLocalStorage(
receiverID: '',
senderID: '',
message: Message()
);
// todo
Function Prototype
- (void)insertSingleMessageToLocalStorage:(OIMMessageInfo *)message
recvID:(NSString *)recvID
sendID:(NSString *)sendID
onSuccess:(nullable OIMMessageInfoCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | OIMMessageInfo | Yes | Message body |
recvID | NSString | Yes | User ID receiving the message |
sendID | NSString | Yes | User ID sending the message |
Return Results
Name | Type | Description |
---|---|---|
onSuccess | OIMMessageInfo | Successful return |
onFailure | OIMFailureCallback | Failed return |
Code Example
[OIMManager.manager insertSingleMessageToLocalStorage:
recvID:@""
sendID:@""
onSuccess:^(OIMMessageInfo * _Nullable message) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void insertSingleMessageToLocalStorage(OnBase<String> base, Message message, String receiver, String sender)
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
base | OnBase<String> | Yes | Callback interface |
message | Message | Yes | Message body |
receiverID | String | Yes | User ID receiving the message |
senderID | String | Yes | User ID sending the message |
Code Example
OpenIMClient.getInstance().messageManager.insertSingleMessageToLocalStorage(new OnBase<AdvancedMessage>() {
public void onError(int code, String error) {
}
public void onSuccess(AdvancedMessage data) {
}
}, message, receiver, sender);
// todo
Function Prototype
IMSDK.insertSingleMessageToLocalStorage({
message: MessageItem;
recvID: string;
sendID: string;
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
message | MessageItem | Yes | Message body |
recvID | string | Yes | User ID receiving the message |
sendID | string | Yes | User ID sending the message |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | 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.insertSingleMessageToLocalStorage({
message: {
// MessageItem
...
};
recvID: "",
sendID: "",
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('insertSingleMessageToLocalStorage', operationID: string,{
message: MessageItem;
recvID: string;
sendID: string;
}): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracking, recommended to be unique using current time and random number |
message | MessageItem | Yes | Message body |
recvID | string | Yes | User ID receiving the message |
sendID | string | Yes | User ID sending the message |
Return Results
The function is promisified through the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to judge and handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi(
'insertSingleMessageToLocalStorage',
IMSDK.uuid(),
{
message: {
// MessageItem
...
},
recvID: "",
sendID: "",
}
)
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.insertSingleMessageToLocalStorage({
message: MessageItem;
recvID: string;
sendID: string;
},operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracking, recommended to be unique using current time and random number |
message | MessageItem | Yes | Message body |
recvID | string | Yes | User ID receiving the message |
sendID | string | Yes | User ID 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.insertSingleMessageToLocalStorage({
message: {
// MessageItem
...
};
recvID: "",
sendID: "",
}, 'operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void InsertSingleMessageToLocalStorage(OnBase<Message> cb, Message message, string recvId, string sendId)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<Message> | Yes | Callback |
message | Message | Yes | Message body |
receiverId | string | Yes | User ID receiving the message |
senderId | string | Yes | User ID sending the message |
Code Example
IMSDK.InsertSingleMessageToLocalStorage((msg,errCode,errMsg)=>{
}, message, receiver, sender);