Create Trip (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.

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.

Below is an example code for creating a trip with two stops. Let's create our stop objects.

let stop = RoamTripStop()
        
stop.address = "address"
stop.metadata = ["key":"value"]
stop.stopName = "name"
stop.stopDescription = "description"
stop.geometryRadius = 100
// logitude , latitude
stop.geometryCoordinates = [10.1,10.1]

Now, let's create a trip object and update the parameters along with the stop created above.

let trip = RoamTrip()
        
trip.user = "userId"
trip.metadata = ["key":"value"]
trip.tripName = "name"
trip.tripDescription = "description"
trip.isLocal = true
trip.stops = [stop]

Now, with the trip and stop objects created, let's create the trip with Roam.createTrip() method.

Roam.createTrip(trip) {response,error in
            // Access status
            // response?.code
            // response?.message
            
            // To access trip details
            let tripDetails = response?.trip
            // Access trip details parameter with tripDetails object
            
            // To access trip user details
            let user = tripDetails?.user
            // Access trip user details parameter with user object
            
            // To access stop details
            let stops = tripDetails?.stops
            //  Access trip stop details parameter with stops array
    
}

The list of responses, error parameters and their description is given below.

To access status parameters:

To access trip response:

To access user details:

To access stop details:

To access the error details:

Last updated