Cloud Integration

Creating Users

Once the SDK is initialised, you 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 to login and access developer APIs. We call this GeoSpark user_Id.

GeoSpark.createUser("SET-USER-DESCRIPTION-HERE") { (geosparkUser, error) in
// access geospark user id with geosparkUser?.userId
// access geospark user description with geosparkUser?.userDescription
// access geospark error code with error?.code
// access geospark error message with error?.message
}

The option user description can be used to update 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 information like an email or phone number.

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

GeoSpark.setDescription("SET-USER-DESCRIPTION-HERE")

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

GeoSpark.getUser("GEOSPARK USER ID") { (geosparkUser, error) in
// access geospark user id with geosparkUser?.userId
// access geospark user description with geosparkUser?.userDescription
// access geospark user description with error?.code
// access geospark user description with error?.message
}

Location Tracking

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

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.

GeoSpark.stopTracking()

Location Publisher

Location update payload objects are published to the backend server 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 in

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 the battery charging?

os_version

Float

Current version of the operating system

device_manufacturer

String

Device manufacturer name

device_model

String

Mobile device model