Zendrive Class Reference
Inherits from | NSObject |
Declared in | Zendrive.h |
Tasks
-
+ setupWithConfiguration:delegate:completionHandler:
-
+ setDelegate:
-
+ getDriveDetectionMode
-
+ setDriveDetectionMode:
-
+ teardownWithCompletionHandler:
-
+ wipeOut:
-
+ startDrive:
-
+ stopDrive
-
+ stopDrive:
-
+ startSession:
-
+ stopSession
-
+ isValidInputParameter:
-
+ isSDKSetup
-
+ zendriveConfiguration
-
+ buildVersion
-
+ activeDriveInfo
-
+ isAccidentDetectionSupportedByDevice
-
+ getEventSupportForDevice
-
+ uploadAllDebugDataAndLogs
Class Methods
activeDriveInfo
Get info on the currently active drive. If sdk is not setup or if no drive is in progress, nil is returned.
+ (nullable ZendriveActiveDriveInfo *)activeDriveInfo
Return Value
The currently active drive information.
Declared In
Zendrive.h
buildVersion
An identifier which can be used to identify this SDK build.
+ (nonnull NSString *)buildVersion
Return Value
An identifier which can be used to identify this SDK build.
Declared In
Zendrive.h
getDriveDetectionMode
The drive detection mode controls how Zendrive SDK detects drives. See ZendriveDriveDetectionMode for further details.
+ (ZendriveDriveDetectionMode)getDriveDetectionMode
Discussion
Use this method to get the current ZendriveDriveDetectionMode.
Declared In
Zendrive.h
getEventSupportForDevice
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.
+ (nonnull NSDictionary *)getEventSupportForDevice
Discussion
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.
Declared In
Zendrive.h
isAccidentDetectionSupportedByDevice
Use this parameter to update zendriveConfiguration.accidentDetectionMode before setup. Calling setup with ZendriveAccidentDetectionModeEnabled on an unsupported device will lead to setup failure.
Curretly supported devices: - All iphones newer than iPhone 4S
+ (BOOL)isAccidentDetectionSupportedByDevice
Return Value
A boolean indicating whether ZendriveSDK can detect accidents on this devices or not.
Declared In
Zendrive.h
isSDKSetup
Is the Zendrive SDK already setup?
+ (BOOL)isSDKSetup
Return Value
YES if Zendrive SDK is already setup. Else NO.
Declared In
Zendrive.h
isValidInputParameter:
Use this method to check whether the parameter string passed to the SDK is valid.
+ (BOOL)isValidInputParameter:(nullable NSString *)input
Parameters
- input
The string to validate.
Return Value
YES if the string is nil or valid, NO otherwise.
Discussion
All strings passed as input params to Zendrive SDK cannot contain the following characters- “?”, “ ”, “&”, “/”, “\”, “;”, “#” Non-ascii characters are not allowed.
Declared In
Zendrive.h
setDelegate:
Set delegate to receive callbacks for various events from Zendrive SDK. See ZendriveDelegateProtocol for further details.
+ (void)setDelegate:(nullable id<ZendriveDelegateProtocol>)delegate
Parameters
- delegate
The delegate object to give callbacks on.
Discussion
Calling this if Zendrvie is not setup is a no-op.
See Also
+ setupWithConfiguration:delegate:completionHandler: for further details.
Declared In
Zendrive.h
setDriveDetectionMode:
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.
+ (void)setDriveDetectionMode:(ZendriveDriveDetectionMode)driveDetectionMode
Parameters
- driveDetectionMode
The new drive detection mode.
Discussion
Calling this method stops an ongoing auto-detected drive. Calling this method when the SDK is not setup is a no-op.
Declared In
Zendrive.h
setupWithConfiguration:delegate:completionHandler:
Initializes the Zendrive library to automatically detect driving and collect data. Client code should call this method before anything else in the Zendrive API.
+ (void)setupWithConfiguration:(nonnull ZendriveConfiguration *)zendriveConfiguration delegate:(nullable id<ZendriveDelegateProtocol>)delegate completionHandler:(nullable ZendriveSetupHandler)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.
Discussion
This method authenticates the configuration with the server asynchronously before returning status.
Calling this method multiple times with the same values for sdkApplicationKey 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 operationMode are changed, but driverId and sdkApplicationKey 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 sdkApplicationKey, driverId pair to validate the sdkApplicationKey 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).
Declared In
Zendrive.h
startDrive:
This API allows application to override Zendrive’s auto drive detection algorithm.
+ (void)startDrive:(nonnull NSString *)trackingId
Parameters
- trackingId
Pass a tracking Id to correlate apps internal data with the drive data. Cannot be nil or empty string. Cannot be longer than 64 characters. Sending nil or empty string as tracking id is a no-op. Use isValidInputParameter: to verify that groupId is valid. Passing invalid string is a no-op.
Discussion
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 stopDrive: 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 startDrive: with the same trackingId without calling stopDrive: in between is a no-op. Calling startDrive: with a different trackingId: with implicitly call stopDrive: before starting a new drive.
This is an asynchronous method, [ZendriveDelegateProtocol processStartOfDrive:] is triggered once this finishes with basic information about the drive [Zendrive activeDriveInfo] will return nil until processStartOfDrive: is called
Warning: You need to call stopDrive: to stop drive data collection.
See Also
Declared In
Zendrive.h
startSession:
Applications which want to record several user’s drives as a session may use this call.
+ (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.
Discussion
Start a session in the SDK.
All drives, either automatically detected or started using startDrive:, 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.
Declared In
Zendrive.h
stopDrive
This should be called to indicate the end of a drive started by invoking startDrive:
+ (void)stopDrive
Discussion
Calling it without having initialized the Zendrive SDK is a no-op.
Warning: This method is deprecated. Use stopDrive: method instead.
See Also
Declared In
Zendrive.h
stopDrive:
This should be called to indicate the end of a drive started by invoking startDrive:
+ (void)stopDrive:(nonnull NSString *)trackingId
Parameters
- trackingId
This trackingId should match the trackingId sent to startDrive: while starting the current drive. If the trackingIds do not match, this function is a no-op. Cannot be nil or empty string.
Discussion
This call has no effect on an automatically detected drive that may be in progress. Calling it without having initialized the Zendrive SDK is a no-op.
This is an asynchronous method, [ZendriveDelegateProtocol processEndOfDrive:] is triggered once this successfully finishes with basic information about the drive [Zendrive activeDriveInfo] will return nil after processEndOfDrive: is called.
See Also
Declared In
Zendrive.h
stopSession
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.
+ (void)stopSession
See Also
Declared In
Zendrive.h
teardownWithCompletionHandler:
Stops driving data collection. The application can disable the Zendrive SDK by invoking this method. This method is asynchronous.
+ (void)teardownWithCompletionHandler:(void ( ^ __nullable ) ( void ))handler
Parameters
- handler
Called when method completes. The handler would be invoked on main thread. Can be nil.
Discussion
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.
Declared In
Zendrive.h
uploadAllDebugDataAndLogs
Send a debug report of the current driver to Zendrive.
+ (void)uploadAllDebugDataAndLogs
Discussion
Send a debug report of the current driver to Zendrive.
Declared In
Zendrive.h
wipeOut:
Wipe out all the data that zendrive keeps locally on the device.
+ (BOOL)wipeOut:(NSError *__nullable *__nullable)error
Discussion
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.
Declared In
Zendrive.h
zendriveConfiguration
This returns the current configuration of Zendrive SDK. Returns nil if SDK is not setup.
+ (nullable ZendriveConfiguration *)zendriveConfiguration
Return Value
The configuration that was used to setup the SDK.
Discussion
This returns a copy of Zendrive configuration. Any modifications to the returned object will have no affect on Zendrive SDK.
Declared In
Zendrive.h