createFaceMessageWithIndex
Feature Introduction
Description
Create emoji messages.
Note
For custom emojis, GIFs, etc. If all platforms synchronize a set of emoji packs, you can use the index parameter. If the emoji packs are not synchronized across platforms, you can use the data parameter. In this case, it is recommended to set the 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 | Type | Mandatory | Description |
|---|---|---|---|
| index | int | No | Emoji position, matched by index |
| data | String | No | URL emoji, displayed using URL |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Successful 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 | Type | Mandatory | Description |
|---|---|---|---|
| index | NSInteger | Yes | Index |
| dataStr | NSString | Yes | Content |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Successful return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createFaceMessageWithIndex:0 data:@""];
Function Prototype
public Message createFaceMessage(long index, String data)
Input Parameters
| Parameter Name | Type | Mandatory | Description |
|---|---|---|---|
| index | int | No | Emoji position, matched by index |
| data | String | No | URL emoji, displayed using URL |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Successful 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 | Type | Mandatory | Description |
|---|---|---|---|
| index | number | Yes | Index |
| dataStr | string | Yes | Content |
Return Result
| Parameter Name | 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 }) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
IMSDK.asyncApi('createFaceMessage', operationID: string, {
index: number;
dataStr: string;
}): Promise<MessageItem>
Input Parameters
| Parameter Name | Type | Mandatory | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, for problem location, keep unique, recommended to use current time and a random number |
| index | number | Yes | Index |
| dataStr | string | Yes | Content |
Return Result
Through the
openim-uniapp-polyfillpackage, the function is Promise-based. When calling, usethenandcatchto determine and handle the success and failure callbacks.
| Parameter Name | 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) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDKRN.createFaceMessage({
index: number;
dataStr: string;
}, operationID: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Mandatory | Description |
|---|---|---|---|
| index | number | Yes | Index |
| dataStr | string | Yes | Content |
| operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Callback on successful call |
| Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.createFaceMessage({
index: 0,
dataStr: 'https://xxx/xxx/xx.png',
}, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
public static Message CreateFaceMessage(int index, string data)
Input Parameter
| Parameter Name | Parameter Type | Mandatory | Description |
|---|---|---|---|
| index | int | Yes | Index |
| data | string | Yes | Content |
Return Result
| Parameter Name | Type | Description |
|---|---|---|
| message | Message | Message Struct |
Code Example
var msg = IMSDK.CreateFaceMessage(index,data);