mesibo Location APIs

Accessing and Subscribing to Locations

You can use the MesiboProfile.location() API to access the locations of other users and groups, subject to the access level granted. The MesiboProfile.location() API returns a MesiboProfileLocation object, which can be used to access various location information, subscribe to location updates, and more.


MesiboProfileLocation profileLocation = profile.location();

MesiboLocation location = profileLocation.get();
val profileLocation = profile.location();

val location:MesiboLocation = profileLocation.get();
let profileLocation = profile.location()

let location = profileLocation.get()
MesiboProfileLocation *profileLocation = [profile location];

MesiboLocation *location = [profileLocation get];

If the location is available, the mesibo API will return it immediately. If not, it will return null and then request the location from the server. Upon receiving the location from the server, Mesibo_onLocationReceived will be called with the profile. You can then call the get() API again to obtain the location. In case the server does not have the location or the location has expired, Mesibo_onLocationError will be called.

Once you have a MesiboLocation object, you can access various properties like latitude, longitude, timestamp, etc.

Subscribing to Location Updates

Location subscription allows users to receive real-time notifications for changes in other users' locations. This feature is commonly used in social apps, navigation apps, fleet tracking, etc.

Subscribing to a location is similar to getting a location as explained above. However, instead of get(), it uses the subscribe(duration) API, where duration is the time (in seconds) for which the user wants to subscribe to the location.

MesiboLocation location = profileLocation.subscribe(3600); // subscribe request for 3600 seconds (i hour)

When a user requests a subscription, Mesibo_onLocationRequest will be called on the remote user's app whose location has been requested. The remote user can ignore or approve the location subscription by calling the share() API.

profileLocation.share(3600); // approve subscription for 3600 seconds (i hour)

Alternatively, you can configure your app to automatically approve all subscriptions, which is disabled by default.

If the remote user or the app approves the subscription, Mesibo_onLocationShared will be called on the requester's app.

Get Subscription Status

A user can get the subscription status by calling:

int duration = profileLocation.getSubscriptionStatus(); 

The return value is the duration remaining (in seconds) or 0 if the subscription does not exist or has expired.

Canceling Subscriptions

A user who has requested a subscription can cancel it by calling:

profileLocation.cancelSubscription(); 

Similarly, the user who shared the location can cancel sharing by calling the share() API with a zero duration.

profileLocation.share(0); 

In the next step, we will learn how to search for other users based on their locations.