createLocationMessage
Feature Introduction
Description
Creates a location message, containing the latitude and longitude of the location.
Note
The latitude and longitude need to be obtained independently.
- 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 Value
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 Value
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 Value
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 Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<MessageItem>> | Success Callback |
Promise.catch() | Promise<WsResponse> | Error 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 }) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
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 for problem diagnosis, unique, recommended current time with random number |
description | string | Yes | Location Description |
latitude | number | Yes | Latitude |
longitude | number | Yes | Longitude |
Return Value
Using the
openim-uniapp-polyfill
package, the function is Promise-ified. When calling, you should usethen
andcatch
to judge and handle success and error callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<MessageItem> | Success Callback |
Promise.catch() | Promise<CatchResponse> | Error Callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('createLocationMessage', IMSDK.uuid(), {
description: '',
longitude: 0,
latitude: 0,
})
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
Function Prototype
OpenIMSDKRN.createLocationMessage({
description: string,
longitude: number,
latitude: number,
}, operationID: string): Promise<MessageItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
description | string | Yes | Location Description |
latitude | number | Yes | Latitude |
longitude | number | Yes | Longitude |
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.createLocationMessage({
description: '',
longitude: 0,
latitude: 0,
}, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Error
});
Function Prototype
public static Message CreateLocationMessage(string description, double longitude, double latitude)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
description | string | Yes | Description |
latitude | double | Yes | Latitude |
longitude | double | Yes | Longitude |
Return Result
Parameter Name | Type | Description |
---|---|---|
~ | Message | Message Struct |
Code Example
var msg = IMSDK. CreateLocationMessage(description,longitude,latitude);