Subscribe Trip (iOS)
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.
Note: For tracking without user sessions, i.e., self tracking, you can only listen to location, errors and offline trip status data since the locations are not being sent to our servers for event processing.
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.
Last updated