createFaceMessageWithIndex
Description
info
Create a face/emoji message.
Note
Custom emojis, animations, etc. If all platforms synchronize the same set of emojis, you can use the index parameter. If platforms do not synchronize emojis, you can use the data parameter, in which case it is recommended to set index to -1.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createFaceMessage({
int index = -1,
String? data,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | int | No | Position emoji, matching based on index |
| data | String | No | URL emoji, display directly using URL |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createFaceMessage(
data: 'https://xxx/xxx/xx.png'
);
//todo
Function Prototype
+ (OIMMessageInfo *)createFaceMessageWithIndex:(NSInteger)index
data:(NSString *)dataStr;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | NSInteger | Yes | Index |
| dataStr | NSString | Yes | Content |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createFaceMessageWithIndex:0 data:@""];
Function Prototype
public Message createFaceMessage(long index, String data)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | int | No | Position emoji, matching based on index |
| data | String | No | URL emoji, display directly using URL |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager.createFaceMessage( index, data)
//todo
Function Prototype
IMSDK.createFaceMessage({
index: number;
dataStr: string;
}, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | number | Yes | Index |
| dataStr | string | Yes | 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.createFaceMessage({
index: 0,
dataStr: 'https://xxx/xxx/xx.png',
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createFaceMessage', operationID: string, {
index: number;
dataStr: 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 |
| index | number | Yes | Index |
| dataStr | string | Yes | 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('createFaceMessage', IMSDK.uuid(), {
index: 0,
dataStr: 'https://xxx/xxx/xx.png',
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createFaceMessage({
index: number;
dataStr: string;
}, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | number | Yes | Index |
| dataStr | string | Yes | 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.createFaceMessage({
index: 0,
dataStr: 'https://xxx/xxx/xx.png',
})
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateFaceMessage(int index, string data)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| index | int | Yes | Index |
| data | string | Yes | Content |
Return Result
| Name | Type | Description |
|---|---|---|
| message | Message | Success return |
Code Example
var msg = IMSDK.CreateFaceMessage(index,data);