Browse SDKs · iOS
Platform
SDKsiOS

Create a location message

Create a location message with OpenIM iOS SDK.

Copy

Invoke createLocationMessage:latitude:longitude: on OIMMessageInfo to construct a location message object containing geographical coordinates and a text description:

Parameters

ParameterTypeRequiredDescription
descriptionNSString *YesLocation name or detailed address description text.
latitudedoubleYesLatitude coordinate value.
longitudedoubleYesLongitude coordinate value.

Code example

OIMMessageInfo *message =
    [OIMMessageInfo createLocationMessage:@"Pudong New Area, Shanghai"
                                 latitude:31.2304
                                longitude:121.4737];

Return value

Returns an initialized OIMMessageInfo model with its content type set to location.

State changes after the call

  1. Local memory instantiation: This method builds an in-memory message model without persisting records to local storage or making network requests.
  2. Coordinate system coordination: The SDK does not invoke system location services or perform coordinate conversions. Ensure that sender and receiver clients agree on a coordinate system convention (such as WGS-84 or GCJ-02).
  3. Subsequent dispatch: Call Send a message to deliver the location message.