Roam.ai Docs
HomeContactDashboard
  • Introduction
  • Getting Started
    • Key Concepts
  • Frameworks
  • Android
    • Quickstart (Android)
    • Pub/Sub Locations (Android)
    • SDK Methods (Android)
      • SDK Configuration (Android)
      • Get Current Location (Android)
      • Update Current Location (Android)
      • Update Location When Stationary (Android)
      • Trip v1 SDK Methods (Android)
      • Trip v2 SDK Methods (Android)
        • Create Trip (Android)
        • Update Trip (Android)
        • Start Quick Trip (Android)
        • Start Trip (Android)
        • End Trip (Android)
        • Pause Trip (Android)
        • Resume Trip (Android)
        • Sync Trip (Android)
        • Get Trip (Android)
        • Get Active Trips (Android)
        • Get Trip Summary (Android)
        • Subscribe to Trip (Android)
        • Delete Trip (Android)
    • Utility Methods (Android)
    • Troubleshooting (Android)
    • Changelog (Android)
  • iOS
    • Quickstart (iOS)
    • Pub/Sub Locations (iOS)
    • SDK Methods (iOS)
      • SDK Configuration (iOS)
      • Get Current Location (iOS)
      • Update Current Location (iOS)
      • Update Location When Stationary (iOS)
      • Trips v1 SDK Methods (iOS)
      • Trips v2 SDK Methods (iOS)
        • Create Trip (iOS)
        • Update Trip (iOS)
        • Start Quick Trip (iOS)
        • Start Trip (iOS)
        • End Trip (iOS)
        • Pause Trip (iOS)
        • Resume Trip (iOS)
        • Sync Trip (iOS)
        • Get Trip (iOS)
        • Get Active Trips (iOS)
        • Get Trip Summary (iOS)
        • Subscribe Trip (iOS)
        • Delete Trip (iOS)
    • Utility Methods (iOS)
    • Troubleshooting (iOS)
    • Changelog (iOS)
  • React Native
  • Flutter
  • PRODUCTS
  • Tracking (BETA)
  • Geofencing
  • Trips
  • APIs
    • Authorization
    • Users API
      • Create User API
      • Get User API
      • Update User API
    • Locations API
      • Get Locations API
      • Get Stop Locations API
    • Insights API
      • Get User POIs API
      • Get User Home Location API
      • Get User Work Location API
    • Trips v1 API
      • Create Trip API v1
      • Get Trip API
      • Update Trip API v1
      • Delete Trip API v1
      • Trip Summary API
      • Export Trip Summary as GPX
    • Trips v2 API
      • Create Trip API
      • Get Single Trip API
      • Get Multiple Trips API
      • Update Trip API
      • Control Trip API
        • Start Trip API
        • Pause Trip API
        • Resume Trip API
        • End Trip API
      • Get Trip Summary API
      • Export Trip API
      • Delete Trip API
    • Geofencing API
      • CREATE Geofence API
      • GET Geofence API
      • UPDATE Geofence API
      • DELETE Geofence API
    • Events API
      • Get Events
      • Trip Events
    • Nearby API
      • Get Nearby User API
      • Get Nearby Geofence API
    • Moving Geofence API
      • Create Moving-Geofence API
      • Update Moving-Geofence API
      • GET Moving-Geofence API
      • Delete Moving-Geofence API
    • User Groups API
      • Create Group API
      • Get User Group by ID
      • Get User Group List
      • Add Users to Group API
      • Update Group API
      • Find Nearby Users from Group
    • Query with Metadata
  • WEBHOOK
    • Webhook
    • Slack Integration
  • LIBRARIES
    • Javascript Library
    • Go Library
    • Python Library
Powered by GitBook
On this page
  • Quick Start & End Trip
  • Create Trip
  • Get Trip Details
  • Start and Stop Trip
  • Pause and Resume Trip
  • Subscribe to Trip Status
  • Get Trip Status
  • Get Trip Summary

Was this helpful?

Export as PDF
  1. iOS
  2. SDK Methods (iOS)

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 
}];

PreviousUpdate Location When Stationary (iOS)NextTrips v2 SDK Methods (iOS)

Last updated 2 years ago

Was this helpful?