Explore all of Roam's iOS SDK methods.
The first step is to configure the iOS SDK.
Parameter
Description
STATE
RoamTrackingState.Foreground (or) RoamTrackingState.Background (or)
RoamTrackingState.AlwaysOn
Parameter
Description
Bool
true (default) -- Offline location enabled. false -- Offline location disabled.
For enabling accuracy engine for Passive, Active, and Balanced tracking,
For Custom tracking modes, you can pass the desired accuracy values in integers ranging from 1-150m.
For disabling accuracy engine,
Call the method to get the current location of the user at your desired accuracy level.
This method gets the current location of the user. You can set the accuracy between 5 and 100 meters (default is 10).
Call the method to update the current location of a user.
Using the updateCurrentLocation
method, you can update the user's current location. You can set the accuracy between 5 and 100 meters (default is 10).
You can now send custom meta-data JSON values along with updateCurrentLocation
method.
Call the method to periodically pick up a user's location when they are stationary. Customize the time interval in seconds.
By using this method updateLocationWhenStationary
, location will update every x
seconds when the device goes into a stationary state.
Except for time-based custom tracking, this will operate in all tracking modes, including active, passive, balance, and distance based custom tracking.
Explore the iOS SDK Methods for Trip API v1. Check out the latest methods if you are using Trips API v2!
The SDK can start a quick trip with a single function which accepts optional values for tracking modes, origin and destinations.
You can now stop the trip and control the tracking modes directly from the stop trip method. This allows you to either force stop location tracking or change the tracking mode using the stop trip method.
You can also use the below methods to manually create a trip and then use the tripID to start the trip.
Use the code below to create a trip directly from the SDK. Set the Boolean value to true
to create an offline trip and false
to create an online trip.
Start trip starts the trip with the previously created tripID.
Pause trip pauses a previously started trip with its tripID.
Resume trip resumes a previously paused trip.
Subscribe to tripStatus
using the tripId
to get real-time trip status.
To stop receiving trip status updates, use the method below.
Explore the Trips v2 SDK Methods for iOS.
Explore how to create a trip on iOS with Trips v2.
To create a trip, you need to create a trip object and assign it with the RoamTrip() class. Below are the parameters and their descriptions for the trip object.
metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
tripName
string
The trip name
tripDescription
string
The trip’s description
isLocal
boolean
The value determining if the trip is a local trip.
user
string
The user object
stops
array
The list of stop object
When you create a trip, you can add stop locations which are nothing but locations where the user taking the trip will receive events for entry and exit. To create and assign stops to a trip, create objects for a single or multiple stops and assign them with the RoamTripStops() class. Below are the parameters and their descriptions for the stop object.
metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
stopName
string
The stop name
stopDescription
string
The stop description
geometryRadius
number
The stop radius
geometryCoordinates
array
Coordinates with longitude, latitude.
address
string
The stop address
Below is an example code for creating a trip with two stops. Let's create our stop objects.
Now, let's create a trip object and update the parameters along with the stop created above.
Now, with the trip and stop objects created, let's create the trip with Roam.createTrip() method.
The list of responses, error parameters and their description is given below.
To access status parameters:
response?.code
number
The response code of the method.
response?.message
string
The response message of the method.
To access trip response:
Parameter
Type
Description
tripDetails?.tripId
number
Unique identifier for the trip object.
tripDetails?.metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
tripDetails?.tripName
string
The trip name
tripDetails?.tripDescription
string
The trip description
tripDetails?.tripState
string
The current state of the trip, created, started, or ended.
tripDetails?.isLocal
boolean
Value determining if the trip is a local trip.
tripDetails?.totalDistance
number
The total distance covered by the user for this trip.
tripDetails?.totalDuration
number
The total duration taken by the user for this trip.
tripDetails?.totalElevationGain
number
The total elevation gain covered by the user for this trip.
tripDetails?.createdAt
string
Timestamp of when the trip was created
tripDetails?.updatedAt
string
Timestamp of when the trip was updated
tripDetails?.startedAt
string
Timestamp when the trip was started by the user
tripDetails?.endedAt
string
Timestamp when the trip was ended by the user
To access user details:
Parameter
Type
Description
user?.userId
string
Unique identifier for the user object.
user?.metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
user?.userDescription
string
User description
user?.userName
string
User's full name
To access stop details:
Parameter
Type
Description
stops?[i].stopName
string
The stop name
stops?[i].stopDescription
string
The stop description
stops?[i].metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
stops?[i].geometryRadius
string
The stop radius
stops?[i].geometryCoordinates
array
Coordinates with longitude , latitude.
stops?[i].arrivedAt
string
Timestamp of when the user arrived at the stop
stops?[i].departedAt
string
Timestamp of when the user departed from the stop
stops?[i].address
string
The stop address
To access the error details:
Parameter
Type
Description
error?.code
number
The error response code of the method.
error?.message
string
The error response message of the method.
error?.errorDescription
string
The error response description of the method.
errorDetails?[i].message
string
The message for error details.
errorDetails?[i].field
string
The field for error details.
Explore how to update a trip on iOS with Trips v2.
The Update Trip method allows you to update your trip details at any point in time. However, you can update the stop locations as long as the trip has not started. You need to create a new object or update the existing trip, assign it with the RoamTrip()
class and pass the trip object to Roam.updateTrip(trip)
.
The trip response and its parameters are similar to those of the createTrip() method.
There's no need to exclusively specify if the trip is local using a boolean value. The updateTrip() method will check that for you and update the trip details accordingly.
Explore how to start a quick trip on iOS with Trips v2.
The Start Quick Trip method creates and starts a trip immediately.
To create a quick trip, you need to create an object for the trip and assign it with theRoamTrip()
class. Below are the parameters and their descriptions for the trip object.
metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
tripName
string
Name of the trip
tripDescription
string
Trip description
isLocal
boolean
Value determining if the trip is a local trip.
Along with the above trip object, you need to pass an additional parameter for trackingMode
which is optional and defaults to active tracking mode.
To start a quick trip with custom tracking mode, refer to the following code:
The list of responses, error parameters and their description is given below.
To access the status parameters:
response?.code
number
The response code of the method.
response?.message
string
The response message of the method.
To access trip response:
tripDetails?.tripId
number
Unique identifier for trip objects.
tripDetails?.metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
tripDetails?.tripName
string
Name of the trip.
tripDetails?.tripDescription
string
Trip description
tripDetails?.tripState
string
The current state of the trip is either created, started, or ended.
tripDetails?.isLocal
boolean
Value determining if the trip is a local trip.
tripDetails?.totalDistance
number
The total distance covered by the user for this trip.
tripDetails?.totalDuration
number
The total duration taken by the user for this trip.
tripDetails?.totalElevationGain
number
The total elevation gain covered by the user for this trip.
tripDetails?.createdAt
string
Timestamp of wen the trip was created
tripDetails?.updatedAt
string
Timestamp of when the trip was updated
tripDetails?.startedAt
string
Timestamp of when the trip was started by the user
tripDetails?.endedAt
string
Timestamp of when the trip was ended by the user
To access user details:
user?.userId
string
Unique identifier for the user object.
user?.metadata
dictionary
A set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
user?.userDescription
string
User description
user?.userName
string
User's full name
To access error details:
error?.code
number
The error response code of the method.
error?.message
string
The error response message of the method.
error?.errorDescription
string
The error response description of the method.
errorDetails?[i].message
string
The message for error detail.
errorDetails?[i].field
string
The field for error detail.
Explore how to start a trip on iOS with Trips v2.
To start a planned trip, you need to pass the tripID with theRoam.endTrip("tripId")
method.
The trip response and its parameters are similar to those of the createTrip()
method.
Explore how to end a trip on iOS with Trips v2.
To end the trip, you need to pass the tripID with the Roam.endTrip("tripId")
method.
The trip response and its parameters are similar to those of the createTrip()
method.
Explore how to pause a trip on iOS with Trips v2.
To pause the trip, you need to pass the tripID with the Roam.pauseTrip("tripId")
method.
The trip response and its parameters are similar to those of the createTrip()
method.
Explore how to resume a trip on iOS with Trips v2.
To resume the trip, you need to pass the tripID with the Roam.resumeTrip("tripId")
method.
The trip response and its parameters are similar to those of the createTrip()
method.
Explore how to sync a trip on iOS with Trips v2.
To sync a trip, you need to pass the tripID with the Roam.syncTrip("tripId")
method.
You can access the sync trip response parameters below:
response?.code
number
The success response code of the method.
response?.message
string
The success response message of the method.
response?.messageDescription
string
Error response description of the method.
response?.tripId
string
Unique identifier for the trip object.
response?.isSynced
boolean
Boolean value to determine if the trip is synced.
Explore how to get the details of a trip on iOS with Trips v2.
To get the details of the trip anytime, you can use the Roam.getTrip("tripId") method by passing the tripId.
The trip response and its parameters are similar to those of the createTrip()
method.
There's no need to exclusively specify if the trip is local or not using a boolean value. The getTrip()
method will check that for you and update the trip details accordingly.
Explore how to get a user's active trips on iOS with Trips v2.
To get the users' active trips, you can use the Roam.getActiveTrips(isLocal)
method where the value of isLocal is boolean. The value being true returns all the local trips and value being false, returns all active trips created on the server side..
The Get Active trips method returns all the trips in the form of a list. The parameters and responses are similar to those of the createTrip()
method.
Explore how to get the summary of a trip on iOS with Trips v2.
To get a summary of the trip anytime, you can use the Roam.getTripSummary("tripId")
method and pass the tripID.
The trip response and its parameters are similar to those of the createTrip()
method.
Explore how to subscribe to a trip on iOS with Trips v2.
For you to subscribe to a trip, you need to pass the tripID with the Roam.subscribeTrip("tripId")
method.
Once you subscribe to the trip, you will receive real time trip data in the listener methods
In order to subscribe to the trips with the listener method, you need to make sure the below is implemented.
To listen to location updates, create a class that implements RoamDeleagate
and then call Roam.delegate.
Set your RoamDelegate
in a code path that will be initialized and executed in the background. For example, ensure that your AppDelegate
and not the ViewController
implements RoamDelegate
. The reason being, AppDelegate
will be initialized in the background, whereas a ViewController
may not be.
You can access the subscribed trip response parameters below:
response.tripId
string
Unique identifier for trip objects.
response.speed
double
Current speed of the subscribed trip
response.distance
double
Current distance covered of the subscribed trip
response.duration
double
Current duration taken of the subscribed trip
response.startedTime
string
Timestamp of when the trip was started by the user
response.pace
double
The current pace of the subscribed trip
response.latitude
double
Current latitude coordinates of the subscribed trip
response.longitude
double
Current longitude coordinates of the subscribed trip
You can unsubscribe from trips using the tripID.
Explore how to delete a trip on iOS with Trips v2.
You can delete the trip irrespective of any trip state. To delete the trip, you need to use the tripID with the Roam.deleteTrip("tripId")
method.
You can access the delete trip response parameters below:
response?.code
number
The success response code of the method.
response?.message
string
The success response message of the method.
response?.errorDescription
string
Error response description of the method.
response?.tripId
string
Unique identifier for trip objects.
response?.isDeleted
boolean
Boolean value to determine if the trip has been deleted.