createTextMessage
Description
info
Create a text message.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createTextMessage({
required String text,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| text | String | Yes | Message content |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createTextMessage(text: text);
//todo
Function Prototype
+ (OIMMessageInfo *)createTextMessage:(NSString *)text;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| text | NSString | Yes | Message content |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createTextMessage:@""];
Function Prototype
public Message createTextMessage(String text)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| text | String | Yes | Message content |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createTextMessage(String text)
//todo
Function Prototype
IMSDK.createTextMessage(text: string, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text content |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<MessageItem>> | 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.createTextMessage('text')
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createTextMessage', operationID: string, text: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| text | string | Yes | Text content |
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<MessageItem> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('createTextMessage', IMSDK.uuid(), 'text')
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createTextMessage(textMsg: string, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Text content |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.createTextMessage('text')
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});