Methods for iOS app
SDK Initialization
First, initialize a new RPEntry class instance with a specified device ID. This method must be the first method calling from RaxelPulse SDK in the applicationdidFinishLaunchingWithOptions
method.
RPEntry.initializeSDK()
[RPEntry initializeSDK];
Log in
[RPEntry instance].virtualDeviceToken = @"VIRTUAL_DEVICE_TOKEN";
[[RPEntry instance] setEnableSdk:true];
RPEntry.instance.virtualDeviceToken = "VIRTUAL_DEVICE_TOKEN"
RPEntry.instance.setEnableSdk(true)
Log out
[[RPEntry instance] logout];
RPEntry.instance.logout()
Enable/ Disable SDK
Empty or nil token is not allowed
Enable SDK
[[RPEntry instance] setEnableSdk:true];
RPEntry.instance.setEnableSdk(true)
Disable SDK
Note: It is not necessary to remove virtual device token. If sdk is disabled no any data will be collected.
❗ Starting from 7.0.0 the method triggers the following actions: stops tracking -> stops heartbeats -> forces unsent data upload -> disables the SDK.
[[RPEntry instance] setEnableSdk:false];
RPEntry.instance.setEnableSdk(false)
Disable SDK with enforced trip uploading (deprecated)
using this method, SDK will enforce trip uploading and then will be disabled.
Note: 'setDisableWithUpload' method is deprecated. Now 'setEnableSdk' method must be used.
[[RPEntry instance] setDisableWithUpload];
RPEntry.instance.setDisableWithUpload()
Check SDK status
BOOL isSDKEnabled = [[RPEntry instance] isSDKEnabled];
let isSDKEnabled = RPEntry.instance.isSDKEnabled()
Check required permissions status
BOOL isGranted = [[RPEntry instance] isAllRequiredPermissionsGranted];
let isGranted = RPEntry.instance.isAllRequiredPermissionsGranted()
Enable/ Disable Tracking
Disable tracking doesn't disable SDK and it will continue to send Heartbeats. If you want the SDK to stop sending any data, you have to use Disable SDK method
Enable tracking
[RPEntry instance].disableTracking = NO; //enable tracking
RPEntry.instance.disableTracking = false //enable tracking
Disable tracking
[RPEntry instance].disableTracking = YES; //disable tracking
RPEntry.instance.disableTracking = true //disable tracking
Manual start/ stop tracking
Manual start tracking
Manual start tracking doesn't disable automatic stop tracking.
[[RPEntry instance] startTracking];
RPEntry.instance.startTracking()
Manual stop tracking
[[RPEntry instance] stopTracking];
RPEntry.instance.stopTracking()
Persistent Tracking
Persistent tracking ignores all stop tracking reasons and continues before 'stopTracking' method will be called. Max persistent tracking duration is 10 hours. then, it will be automatically terminated.
[[RPEntry instance] startPersistentTracking];
RPEntry.instance.startPersistentTracking()
Enable Aggressive Heartbeats
The telematics SDK supports two operational modes for heartbeats;
Aggressive heartbeats- heartbeats are sent every 20 minutes. SDK is always active.
Normal Heartbeats - heartbeats are sent every 20 minutes but when SDK turns into Standby mode, it will be activated only by a new trip, and heartbeat will be sent respectively.
Note: Aggressive heartbeats significantly increases battery usage
Example:
[[RPEntry instance] setAggressiveHeartbeats:NO];
RPEntry.instance.setAggressiveHeartbeats(false)
Check state
Example:
[[RPEntry instance] aggressiveHeartbeat];
RPEntry.instance.aggressiveHeartbeat()
Enable Ads ID
To enable Ads ID, you have to provide an Advertisement identifier to SDK. Please add these lines near the code from the previous section. Make sure, you added import
section
#import <AdSupport/AdSupport.h>
Enable high-frequency data collection (HF)
HF data is enabled by default.
Enable Accidents detection.
Accidents detection is disabled by default. You can enable detection.
In order for accidents detection to work, you need to enable high-frequency data collection
[[RPEntry instance] enableAccidents:true];
RPEntry.instance.enableAccidents(true)
Enable Bluetooth OBD
Bluetooth OBD/ELM functionality enables the host app to work with Bluetooth OBD devices to get in-vehicle data 👉 Dataset . To enable this, please use the method below:
[[RPEntry instance] enableELM:YES];
RPEntry.instance.enableELM(true)
Connect Bluetooth OBD
Please refer to a special page that we created for the Bluetooth OBD integration
Setting up for iOS app
Setting up for Android app
Tags
The detailed information about using Tags is available here
Get a list of trips
[[RPEntry instance].api getTracksWithOffset:0
limit:10
startDate:nil
endDate:nil
ompletion:^(NSArray<RPTrackProcessed *> * _Nonnull tracks, NSError * _Nullable error) {
if (error) {
/// Implement updating your ViewController with error
return;
}
/// Implement updating your ViewController with new data
}];
RPEntry.instance.api.getTracksWithOffset(0, limit: 10) { tracks, error in
if let error {
/// Implement updating your ViewController with error
return
}
/// Implement updating your ViewController with new data
}
Get trip details
[[RPEntry instance].api getTrackWithTrackToken:@"SELECTED_TRACK_TOKEN"
completion:^(RPTrackProcessed * _Nullable track, NSError * _Nullable error) {
if (error) {
/// Implement updating your ViewController with error
return;
}
if (track) {
/// Implement updating your ViewController with new data
}
}];
RPEntry.instance.api.getTrackWithTrackToken("SELECTED_TRACK_TOKEN") { track, error in
if let error {
/// Implement updating your ViewController with error
return
}
if let track {
/// Implement updating your ViewController with new data
}
}
Change a Transportation type
[[RPEntry instance].api changeTrackOrigin:RPTrackOriginCodeOriginalDriver
forTrackToken:@"SELECTED_TRACK_TOKEN'"
completion:^(RPStatusCodeResponse * _Nullable status, NSError * _Nullable error) {
}];
//Avilable origins:
//RPTrackOriginCodeOriginalDriver
//RPTrackOriginCodeBicycle
//RPTrackOriginCodeBus
//RPTrackOriginCodeMotorcycle
//RPTrackOriginCodeOther
//RPTrackOriginCodePassenger
//RPTrackOriginCodeRunning
//RPTrackOriginCodeTaxi
//RPTrackOriginCodeTrain
//RPTrackOriginCodeWalking
RPEntry.instance.api.changeTrackOrigin(.originalDriver, forTrackToken: "SELECTED_TRACK_TOKEN") { code, error in
}
//Avilable origins:
//.originalDriver
//.bus
//.motorcycle
//.other
//.passenger
//.running
//.taxi
//.train
//.walking
Upload unsent trips
[[RPEntry instance] uploadUnsentTrips];
RPEntry.instance.uploadUnsentTrips()
Get unsent trips
NSInteger count = [[RPEntry instance] getUnsentTripCount];
NSLog(@"unsent trips count - %ld", (long)count);
let count = RPEntry.instance.getUnsentTripCount()
print("unsent trips count - \(count)")
Send a custom heartbeat
[[RPEntry instance] sendCustomHeartbeat:@"CustomHeartbeat" completion:^(Boolean success, NSError * _Nullable error) {
if (error) {
NSLog(@"error - %@", error.localizedDescription);
}
}];
RPEntry.instance.sendCustomHeartbeat("CustomHeartbeat") { success, error in
if let error {
print("error - \(error.localizedDescription)")
}
}
Updated 2 days ago