Trips v1 SDK Methods (iOS)
Explore the iOS SDK Methods for Trip API v1. Check out the latest methods if you are using Trips API v2!
Quick Start & End Trip
The SDK can start a quick trip with a single function which accepts optional values for tracking modes, origin and destinations.
// tripId as String
// localTrip as Bool
// RoamTrackingMode
// tripDescription as string
// origin as Array<Array<Double>> [[latitude,longitude],[latitude,longitude]]
// destination as Array<Array<Double>> [[latitude,longitude],[latitude,longitude]]
// option for custom tracking RoamTrackingCustomMethods
Roam.startTrip("tripId", false, RoamTrackingMode.active, "tripDescription", origins, destination ) { startTrip, error in
// access roam trip created timestamp with roamTrip?.createdAt
// access roam trip user id with roamTrip?.userId
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
// tripId as String
// localTrip as Bool
// RoamTrackingMode
// tripDescription as string
// origin as Array<Array<Double>> [[latitude,longitude],[latitude,longitude]]
// destination as Array<Array<Double>> [[latitude,longitude],[latitude,longitude]]
// option for custom tracking RoamTrackingCustomMethods
[Roam startTrip:@"tripId" :BOOL :RoamTrackingModeActive :@"tripDescription" :origins :destination :RoamTrackingCustomMethods handler:^(RoamStartTrip * startTrip, RoamError * error) {
}];
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.
// tripId as String
// forceStopTracking as Bool
// RoamTrackingMode
// option for custom tracking RoamTrackingCustomMethods
Roam.stopTrip("tripId", forceStopTracking: true, RoamTrackingMode, RoamTrackingCustomMethods) { roamStatus, roamError in
// access trip status with roamStatus
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam stopTrip:@"" forceStopTracking:false :RoamTrackingModeActive :RoamTrackingCustomMethods handler:^(NSString * status, RoamError * error) {
}];
You can also use the below methods to manually create a trip and then use the tripID to start the trip.
Create 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.
Roam.createTrip(Bool, nil) { (roamTrip, roamError) in
// access roam trip created timestamp with roamTrip?.createdAt
// access roam trip user id with roamTrip?.userId
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam createTrip:true :nil handler:^(RoamCreateTrip * roamTrip, RoamError * roamError) {
// access roam trip created timestamp with roamTrip?.createdAt
// access roam trip user id with roamTrip?.userId
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Get Trip Details
Roam.getTripDetails("ROAM-TRIP-ID") { (roamTrip, roamError) in
// access roam trip created timestamp with roamTrip?.createdAt
// access roam trip user id with roamTrip?.userId
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam getTripDetails:@"ROAM-TRIP-ID" handler:^(RoamGetTrip * roamTrip, RoamError * roamError) {
// access roam trip created timestamp with roamTrip?.createdAt
// access roam trip user id with roamTrip?.userId
// access roam trip id with roamTrip?.tripId
// access roam error code with roamTrip?.code
// access roam error message with roamError?.message
}];
Start and Stop Trip
Start Trip
Start trip starts the trip with the previously created tripID.
Roam.startTrip("ROAM-TRIP-ID") { (status, roamError) in
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam startTrip:@"ROAM-TRIP-ID" :@"ROAM-TRIP-DESC" handler:^(NSString * status, RoamError * roamError) {
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Stop Trip
Roam.stopTrip("ROAM-TRIP-ID") { (status, roamError) in
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam stopTrip:@"ROAM-TRIP-ID" handler:^(NSString * status, RoamError * roamError) {
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Pause and Resume Trip
Pause Trip
Pause trip pauses a previously started trip with its tripID.
Roam.pauseTrip("ROAM-TRIP-ID") { (status, error) in
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam pauseTrip:@"ROAM-TRIP-ID" handler:^(NSString * status, RoamError * roamError) {
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Resume Trip
Resume trip resumes a previously paused trip.
Roam.resumeTrip("ROAM-TRIP-ID") { (status, roamError) in
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam resumeTrip:@"ROAM-TRIP-ID" handler:^(NSString * status, RoamError * roamError) {
// access roam trip status with status
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Subscribe to Trip Status
Subscribe to tripStatus
using the tripId
to get real-time trip status.
//subscribe to trip status
Roam.subscribeTripStatus("ROAM-TRIP-ID")
//subscribe to trip status
[Roam subscribeTripStatus:@"ROAM-TRIP-ID")
To stop receiving trip status updates, use the method below.
// unsubscribe from all the trip
Roam.unsubscribeTripStatus()
// unsubscribe from trip
Roam.unsubscribeTripStatus('ROAM-TRIP-ID')
// unsubscribe from all the trip
[Roam unsubscribeTripStatus:NULL];
// unsubscribe from trip
[Roam unsubscribeTripStatus:@"ROAM-TRIP-ID"];
Get Trip Status
Roam.getTripStatus("ROAM-TRIP-ID") { (roamTrip, roamError) in
// access roam trip distance covered with roamTrip?.distance
// access roam trip speed with roamTrip?.speed
// access roam trip duration with roamTrip?.duration
// access roam trip id with roamTrip?.tripId
// access roam trip started timestamp with roamTrip?.startedAt
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam getTripStatus:@"ROAM-TRIP-ID" handler:^(RoamTripListener * roamTrip, RoamError * roamError) {
// access roam trip distance covered with roamTrip?.distance
// access roam trip speed with roamTrip?.speed
// access roam trip duration with roamTrip?.duration
// access roam trip id with roamTrip?.tripId
// access roam trip started timestamp with roamTrip?.startedAt
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Get Trip Summary
Roam.getTripSummary("ROAM-TRIP-ID") { (roamTrip, roamError) in
// access roam trip distance covered with roamTrip?.distanceCovered
// access roam trip route with roamTrip?.route
// access roam trip duration with roamTrip?.duration
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}
[Roam getTripSummary:@"ROAM-TRIP-ID" handler:^(RoamTripSummary * roamTrip, RoamError * roamError) {
// access roam trip distance covered with roamTrip?.distanceCovered
// access roam trip route with roamTrip?.route
// access roam trip duration with roamTrip?.duration
// access roam trip id with roamTrip?.tripId
// access roam error code with roamError?.code
// access roam error message with roamError?.message
}];
Last updated