Trip Control Methods on Kruzr iOS SDK

Now that you have set-up and integrated trip detection, user registration functionalities into your Kruzr SDK, it is now time to see the trip related controls and corresponding methods available for your app.

While implementing these, it is important that you understand the purpose and function of each of these methods. We would request that please go through our section on Understanding Features & Methods of Kruzr SDK section if you have not already.

Register User

Once user got logged in, need to register user with SDK by calling registerUser in TripManager.

import KruzrTripFramework

TripManager.sharedInstance.registerUser(user:KruzrTripUser) { (success,error) in
    if success { 
        print("User has been registered successfully.")
    }
}

public func registerUser(user:KruzrTripUser,completion:@escaping (Bool,ApiError2?)

Start Trip Manually

Manual Start Trip method is a useful way to provide your users with control over starting the trip themselves if they prefer it over Automatic Trip Detection. It also helps you make your app more complete in terms of possible user flows.

Please note that Start Trip Manually is part of didTripStarted() function. In case Start Trip is successful or if there is any exception, you will receive a callback from didTripStarted() function.

import KruzrTripFramework

TripManager.sharedInstance.startManualTrip()

Stop Trip Manually

Allows the user to manually end an ongoing trip. Please note that the trip may be automatically started or manually started - in either of the cases, an ongoing trip can be terminated/stopped using this method.

Note: Within the Kruzr system, it is not a mandatory implementation since all on-going trips are Auto-Stopped via SDK if driving movement has stopped. However, providing option of manual override is preferable since it provides more control to your users over their trips

Please note that Start Trip Manually is part of didTripStarted() function. In case Start Trip is successful or if there is any exception, you will receive a callback from didTripStarted() function.

import KruzrTripFramework
 
TripManager.sharedInstance.manualTripEnd()

Get Trip List

Trip list provides your app a method to fetch all the trips for a particular user within your app.

Please call getAllTrips method with the following parameters -

  • offset - the starting point/reference from which you need to fetch trips.

  • limit - how many trips you want to be fetched

getAllTrips(limit:Int, offset:Int) {
    (statusCode, results, error) in
    if statusCode == 200 {
         print(“Results: \(results).”)
    } else {
        print(“error:\(error.message)”)
    }
}

It is recommended as to use combination of limit and offset while loading trip lists for users in your app. It will help you reduce the need making bulk downloads of all trips, specially in cases where number of trips for the user is very high. So, for example, if you want to fetch 12 trips between position 30 and 42, you will set offset as 30 and limit as 12.

Get Details of Completed Trip

Please call getTripDetail method, passing tripID as a parameter to get trip summary details for a completed trip. You can use this information to engage drivers for their historic trips on a trip summary page.

getTripDetail(tripID:String) {
    (statusCode, results, error) in
   if statusCode == 200 {
         print(“Results: \(results).”)
    } else {
        print(“error:\(error.message)”)
    }
}

Great! You have completed all methods and integrated Kruzr SDK into your application successfully. Please continue reading to our "Important Developer Notes & Updates" section to stay up to date about latest change in Android, iOS platforms and Kruzr SDKs!

Last updated

Was this helpful?