Zendrive

@interface Zendrive : NSObject

Zendrive Object.

  • Initializes the Zendrive library to automatically detect driving and collect data. Client code should call this method before anything else in the Zendrive API.

    This method authenticates the configuration with the server asynchronously before returning status.

    Calling this method multiple times with the same values for applicationKey and driverId pair is a no-op. Changing either will be the same as calling teardown followed by calling setup with the new parameters. Please note that even if other configuration parameters like driverAttributes or driveDetectionMode are changed, but driverId, applicationKey and region remain same, calling this method would still be a no-op. If you want to change these configuration parameters, invoke teardown explicitly and call this method again with the new configuration.

    This method requires network connection for every time the setup is called with a different value for applicationKey, driverId pair to validate the applicationKey from the server. Setup fails and returns NO if network is not available in such cases.

    This method returns NO whenever setup fails and sets up the error with the error code, cause and description.

    When data collection needs to be stopped call the teardown method. This might be done for example when the application’s user has logged out (and possibly a different user might login later).

    Declaration

    Objective-C

    + (void)setupWithConfiguration:
                (nonnull ZendriveConfiguration *)zendriveConfiguration
                          delegate:(nullable id<ZendriveDelegateProtocol>)delegate
                 completionHandler:(nullable ZendriveApiCallHandler)handler;

    Parameters

    zendriveConfiguration

    The configuration object used to setup the SDK. This object contains your credentials along with additional setup parameters that you can use to provide meta-information about the user or to tune the sdk functionality.

    delegate

    The delegate object on which Zendrive SDK will issue callbacks for handling various events. Can be nil if you do not want to register for callbacks. The delegate can also be set at a later point using +setDelegate: method.

    handler

    This block is called when zendrive setup completes. The application is expected to use the success and error params passed to this block to handle failures. The handler would be invoked on the main thread. Can be nil.

  • Set delegate to receive callbacks for various events from Zendrive SDK. See ZendriveDelegateProtocol for further details.

    Calling this if Zendrive is not setup is a no-op.

    Declaration

    Objective-C

    + (void)setDelegate:(nullable id<ZendriveDelegateProtocol>)delegate;

    Parameters

    delegate

    The delegate object to give callbacks on.

  • The drive detection mode controls how Zendrive SDK detects drives. See ZendriveDriveDetectionMode for further details.

    Use this method to get the current ZendriveDriveDetectionMode.

    Declaration

    Objective-C

    + (ZendriveDriveDetectionMode)getDriveDetectionMode;
  • Change the drive detection mode to control how Zendrive SDK detects drives. See ZendriveDriveDetectionMode for further details. This will override the mode sent with ZendriveConfiguration during setup.

    Calling this method stops an ongoing auto-detected drive. Calling this method when the SDK is not setup is a no-op.

    Declaration

    Objective-C

    + (void)setDriveDetectionMode:(ZendriveDriveDetectionMode)driveDetectionMode
                completionHandler:
                    (nullable ZendriveApiCallHandler)completionHandler;

    Parameters

    driveDetectionMode

    The new drive detection mode.

    completionHandler

    A block object to be executed when the task finishes. This block has no return value and two arguments: isSuccess, A boolean that suggests if drive is started successfully error, A valid error of ZendriveErrorDomain.kZendriveErrorDomain (ZendriveError) is returned in case of a failure. Possible error codes returned: kZendriveErrorNotSetup Refer to ZendriveError for more details on the errors.

  • Stops driving data collection. The application can disable the Zendrive SDK by invoking this method. This method is asynchronous.

    The teardown method is internally synchronized with +setupWithConfiguration:delegate:completionHandler: method, and the enclosing application should avoid synchronizing the two methods independently. Calling this with nil completion handler is same as calling teardown method.

    Declaration

    Objective-C

    + (void)teardownWithCompletionHandler:(void (^_Nullable)(void))handler;

    Parameters

    handler

    Called when method completes. The handler would be invoked on main thread. Can be nil.

  • Wipe out all the data that zendrive keeps locally on the device.

    When Zendrive SDK is torn down, trip data that is locally persisted continues to remain persisted. The data will be uploaded when SDK setup is called at a later time. Wipeout should be used when the application wants to remove all traces of Zendrive on the device. Data cannot be recovered after this call. NOTE: This call can only be made when the SDK is not running. Call +teardownWithCompletionHandler: to tear down a live SDK before making this call.

    Declaration

    Objective-C

    + (BOOL)wipeOut:(NSError *_Nullable *_Nullable)error;
  • This API allows application to override Zendrive’s auto drive detection algorithm.

    Invoking this method forces the start of a drive. If this API is used then it is application’s responsibility to terminate the drive by invoking stopManualDrive:completionHandler: method. If an auto-detected drive is in progress, that drive is stopped and a new drive is started.

    These methods should be used only by applications which have explicit knowledge of start and end of drives and want to attribute drive data to specific trackingIds.

    Calling it without having initialized the Zendrive framework (setupWithApplicationId) is a no-op.

    Calling startManualDrive:completionHandler: with the same trackingId without calling stopManualDrive:completionHandler: in between is a no-op. Calling startManualDrive:completionHandler: with a different trackingId: with implicitly call stopManualDrive:completionHandler: before starting a new drive.

    This is an asynchronous method, -[ZendriveDelegateProtocol processStartOfDrive:] is triggered once this finishes with basic information about the drive +activeDriveInfo will return nil until processStartOfDrive: is called

    See

    +stopManualDrive:completionHandler:

    You need to call +stopManualDrive:completionHandler: to stop drive data collection.

    Declaration

    Objective-C

    + (void)startManualDrive:(nullable NSString *)trackingId
           completionHandler:(nullable ZendriveApiCallHandler)completionHandler;

    Parameters

    completionHandler

    A block object to be executed when the task finishes. This block has no return value and two arguments: isSuccess, A boolean that suggests if drive is started successfully error, A valid error of ZendriveErrorDomain.kZendriveErrorDomain (ZendriveError) is returned in case of a failure. Possible error codes returned: kZendriveErrorNotSetup, kZendriveErrorInvalidTrackingId Refer to ZendriveError for more details on the errors.

  • This should be called to indicate the end of a drive started by invoking +startManualDrive:completionHandler:

    This block has no return value and two arguments: the error, A valid error of ZendriveErrorDomain.kZendriveErrorDomain (ZendriveError) is returned in case of a failure. Possible error codes returned: kZendriveErrorNotSetup, kZendriveErrorInvalidTrackingId, kZendriveErrorInternalFailure. Refer to ZendriveError for more details on the errors. isSuccess, A boolean that suggests if drive is stopped successfully

    Calling it without having initialized the Zendrive SDK is a no-op.

    Declaration

    Objective-C

    + (void)stopManualDrive:(nullable ZendriveApiCallHandler)completionHandler;
  • Start a session in the SDK.

    Applications which want to record several user’s drives as a session may use this call.

    All drives, either automatically detected or started using +startManualDrive:completionHandler:, will be tagged with the sessionId if a session is already in progress. If a drive is already on when this call is made, that drive will not belong to this session.

    This session id will be made available as a query parameter in the reports and API that Zendrive provides.

    The application must call +stopSession when it wants to end the session.

    Only one session may be active at a time. Calling startSession when a session is already active with a new sessionId will stop the ongoing session and start a new one.

    Calling it without having initialized the Zendrive SDK is a no-op.

    Declaration

    Objective-C

    + (void)startSession:(nonnull NSString *)sessionId;

    Parameters

    sessionId

    an identifier that identifies this session uniquely. Cannot be null or an empty string. Cannot be longer than 64 characters. Use +isValidInputParameter: to verify that groupId is valid. Passing invalid string is a no-op.

  • Stop currently ongoing session. No-op if no session is ongoing. Trips that start after this call do not belong to the session. Ongoing trips at the time of this call will continue to belong to the session that was just stopped.

    Declaration

    Objective-C

    + (void)stopSession;
  • Use this method to check whether the parameter string passed to the SDK is valid.

    All strings passed as input params to Zendrive SDK cannot contain the following characters- ?, “ ,&,/,\,;,#” Non-ascii characters are not allowed.

    Declaration

    Objective-C

    + (BOOL)isValidInputParameter:(nullable NSString *)input;

    Parameters

    input

    The string to validate.

    Return Value

    YES if the string is nil or valid, NO otherwise.

  • Is the Zendrive SDK already setup?

    Declaration

    Objective-C

    + (BOOL)isSDKSetup;

    Return Value

    YES if Zendrive SDK is already setup. Else NO.

  • Declaration

    Objective-C

    + (nonnull NSString *)buildVersion;

    Return Value

    An identifier which can be used to identify this SDK build.

  • Get info on the currently active drive. If sdk is not setup or if no drive is in progress, nil is returned.

    Declaration

    Objective-C

    + (nullable ZendriveActiveDriveInfo *)activeDriveInfo;

    Return Value

    The currently active drive information.

  • Get the current state of the Zendrive SDK.

    Declaration

    Objective-C

    + (void)getZendriveState:
        (void (^_Nullable)(ZendriveState *_Nullable))completionHandler;

    Parameters

    completionHandler

    A block object to be executed when the task finishes. This block has no return value and a single argument: zendriveState, A ZendriveState object that informs about the current state of the sdk. If the SDK is not set up, the zendriveState is nil.

  • Declaration

    Objective-C

    + (BOOL)isAccidentDetectionSupportedByDevice;

    Return Value

    A boolean indicating whether ZendriveSDK can detect accidents on this devices or not.

  • Returns a NSDictionary with keys as ZendriveEventType and values being BOOL which represent if a particular event will be detected by the SDK on this device.

    Declaration

    Objective-C

    + (nonnull NSDictionary *)getEventSupportForDevice;
  • Send a debug report of the current driver to Zendrive. The ZendriveSDK will create a background task to ensure the completion of this upload task.

    Declaration

    Objective-C

    + (void)uploadAllDebugDataAndLogs;