createLocationMessage
Description
info
Create a location message, including the latitude, longitude, and description of the location.
Note
Latitude and longitude need to be obtained by yourself.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createLocationMessage({
required double latitude,
required double longitude,
required String description,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | String | Yes | Description |
| latitude | double | Yes | Latitude |
| longitude | double | Yes | Longitude |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createLocationMessage(latitude: latitude, longitude: longitude, description: description);
//todo
Function Prototype
+ (OIMMessageInfo *)createLocationMessage:(NSString *)description
latitude:(double)latitude
longitude:(double)longitude;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | NSString | Yes | Description |
| latitude | double | Yes | Latitude |
| longitude | double | Yes | Longitude |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createLocationMessage:@"" latitude:0 longitude:0];
Function Prototype
public Message createLocationMessage(double latitude, double longitude, String description)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | String | Yes | Description |
| latitude | double | Yes | Latitude |
| longitude | double | Yes | Longitude |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createLocationMessage( latitude, longitude, description)
Function Prototype
IMSDK.createLocationMessage({
description: string;
longitude: number;
latitude: number;
}, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | string | Yes | Location description |
| latitude | number | Yes | Latitude |
| longitude | number | Yes | Longitude |
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.createLocationMessage({
description: '',
longitude: 0,
latitude: 0,
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createLocationMessage', operationID: string,{
description: string;
longitude: number;
latitude: number;
}): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| description | string | Yes | Location description |
| latitude | number | Yes | Latitude |
| longitude | number | Yes | Longitude |
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('createLocationMessage', IMSDK.uuid(), {
description: '',
longitude: 0,
latitude: 0,
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createLocationMessage({
description: string,
longitude: number,
latitude: number,
}, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | string | Yes | Location description |
| latitude | number | Yes | Latitude |
| longitude | number | Yes | Longitude |
| 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.createLocationMessage({
description: '',
longitude: 0,
latitude: 0,
})
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateLocationMessage(string description, double longitude, double latitude)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| description | string | Yes | Description |
| latitude | double | Yes | Latitude |
| longitude | double | Yes | Longitude |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
var msg = IMSDK. CreateLocationMessage(description,longitude,latitude);