Cloud Integration

Creating Users

Once the SDK is initialized, we need to create or get a user to start the tracking and use other methods. Every user created will have a unique GeoSpark identifier which will be used later to login and access developer APIs. We can call it as GeoSpark userId.

Kotlin
Java
Kotlin
GeoSpark.createUser("SET USER DESCRIPTION HERE", object : GeoSparkCallback {
override fun onSuccess(geosparkUser: GeoSparkUser) {
// do something when create user success
// access geospark user id with geosparkUser.getUserId()
// access geospark user description with geosparkUser.getDescription()
}
override fun onFailure(geosparkError: GeoSparkError) {
// do something when create user failure
// access geospark error code with geosparkError.getCode()
// access geospark error message with geosparkError.getMessage()
}
})
Java
GeoSpark.createUser("SET USER DESCRIPTION HERE", new GeoSparkCallback() {
@Override
public void onSuccess(GeoSparkUser geosparkUser) {
// do something when create user success
// access geospark user id with geosparkUser.getUserId()
// access geospark user description with geosparkUser.getDescription()
}
@Override
public void onFailure(GeoSparkError geosparkError) {
// do something when create user failure
// access geospark error code with geosparkError.getCode()
// access geospark error message with geosparkError.getMessage()
}
});

The option user description can be used to update your user information such as name, address or add an existing user ID. Make sure the information is encrypted if you are planning to save personal user information like email or phone number.

You can always set or update user descriptions later using the below code.

Kotlin
Java
Kotlin
GeoSpark.setDescription("SET USER DESCRIPTION HERE")
Java
GeoSpark.setDescription("SET USER DESCRIPTION HERE");

If you already have a GeoSpark userID which you would like to reuse instead of creating a new user, use the below to get user session.

Kotlin
Java
Kotlin
GeoSpark.getUser("GEOSPARK USER ID", object : GeoSparkCallback {
override fun onSuccess(geosparkUser: GeoSparkUser) {
// do something when get user success
// access geospark user id with geosparkUser.getUserId()
// access geospark user description with geosparkUser.getDescription()
}
override fun onFailure(error: GeoSparkError) {
// do something when get user failure
// access geospark error code with error.getCode()
// access geospark error message with error.getMessage()
}
})
Java
GeoSpark.getUser("GEOSPARK USER ID", new GeoSparkCallback() {
@Override
public void onSuccess(GeoSparkUser geosparkUser) {
// do something when get user success
// access geospark user id with geosparkUser.getUserId()
// access geospark user description with geosparkUser.getDescription()
}
@Override
public void onFailure(GeoSparkError error) {
// do something when get user failure
// access geospark error code with error.getCode()
// access geospark error message with error.getMessage()
}
});

Location Tracking

Once the tracking mode is configured, use the below code to start tracking.

Kotlin
Java
Kotlin
GeoSpark.startTracking(TrackingMode)
Java
GeoSpark.startTracking(TrackingMode);

You may see a delay if the user's device is in low power mode or has connectivity issues.

To stop the tracking use the below method.

Kotlin
Java
Kotlin
GeoSpark.stopTracking()
Java
GeoSpark.stopTracking();

Location Publisher

Location update payload objects published to the backend server are as below:

Key

Type

Description

latitude

Float

Geographic coordinate north-south

longitude

Float

Geographic coordinate west-east

course

Float

Direction heading in relation to north

speed

Float

Speed in kilometers per hour (only in motion)

altitude

Float

Height above the sea level in meters

horizontal_accuracy

Float

Horizontal accuracy of the coordinates

vertical_accuracy

Float

Vertical accuracy of the coordinates

activity

String

Is the user moving or did they stop?

recorded_at

Datetime

Location recorded at timestamp in UTC

tz_offset

String

Location recorded at timezone

user_id

String

Unique user ID

location_id

String

Unique object ID

app_id

String

Project ID

app_context

String

Application state

gps_status

Boolean

Is GPS tracking enabled?

tracking_mode

String

Tracking mode that the location was collected at

location_permission

Boolean

Is location permission enabled?

network_status

Boolean

Is internet connection enabled?

battery_remaining

Int

Remaining battery in percentage

battery_saver

Boolean

Is battery saver mode enabled?

battery_status

String

Is battery charging?

os_version

Float

Current version of the operating system

device_manufacturer

String

Device manufacturer name

device_model

String

Mobile device model