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

try RPEntry.instance.setDeviceID(deviceId: "DEVICE_ID")
RPEntry.instance.setEnableSdk(true)
NSError *error = nil;
BOOL success = [[RPEntry instance] setDeviceIDWithDeviceId:@"DEVICE_ID"
                                                     error:&error];
if (!success) {
     NSLog(@"Failed to set device id: %@", error);
}
[[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];

Check SDK status


let isSDKEnabled = RPEntry.instance.isSDKEnabled()
BOOL isSDKEnabled = [[RPEntry instance] isSDKEnabled];

Check required permissions status


let isGranted = RPEntry.instance.isAllRequiredPermissionsAndSensorsGranted()
BOOL isGranted = [[RPEntry instance] isAllRequiredPermissionsAndSensorsGranted];

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.setDisableTracking(disableTracking: false) //enable tracking
[[RPEntry instance] setDisableTrackingWithDisableTracking:NO]; //enable tracking

Disable tracking

RPEntry.instance.setDisableTracking(disableTracking: true) //disable tracking
[[RPEntry instance] setDisableTrackingWithDisableTracking:YES]; //disable tracking

Manual start/ stop tracking


Manual start tracking

📘

Manual start tracking doesn't disable automatic stop tracking. Methods startTracking() and stopTracking() must be called on the Main Thread.

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 max is 10 hours. then, it will be automatically terminated.

Method startTrackAsPersistent() must be called on the Main Thread.

RPEntry.instance.startTrackAsPersistent()
[[RPEntry instance] startTrackAsPersistent];

Set max persistent tracking interval

Sets the maximum duration for a single persistent tracking session, in minutes. The SDK uses 240 minutes (4 hours) by default.

Use this method to limit how long persistent tracking may continue before the SDK automatically stops it. This can be used for compliance, battery preservation, or business rules that require capping continuous background tracking.

📘

The allowed range is from 5 minutes up to 600 minutes (10 hours). The method throws an error if the provided value is outside the allowed range.

try RPEntry.instance.setMaxPersistentTrackingInterval(minutes: 240)
NSError *error = nil;
BOOL success = [[RPEntry instance] setMaxPersistentTrackingIntervalWithMinutes:240
                                                                         error:&error];
if (!success) {
    NSLog(@"Failed to set max persistent tracking interval: %@", error);
}

Get max persistent tracking interval

Retrieves the current maximum duration, in minutes, allowed for a single persistent tracking session. The SDK uses this value to automatically stop long-running background tracking sessions once the limit is reached.

let maxPersistentTrackingInterval = RPEntry.instance.getMaxPersistentTrackingInterval()
NSInteger maxPersistentTrackingInterval = [[RPEntry instance] getMaxPersistentTrackingInterval];

Set tracking mode

Sets the tracking mode used by the SDK for both automatically and manually started tracking sessions.

Use this method to define whether tracking sessions started by SDK triggers, such as motion or location activity, should run in .standard or .persistent mode. Persistent tracking continues operating in the background and across app launches until explicitly stopped or until the maximum persistent tracking interval is reached.

📘

Using .persistent may increase battery usage and background activity. Ensure your app is configured with the required location permissions, background modes, and usage descriptions.

RPEntry.instance.setTrackingMode(.standard)
[[RPEntry instance] setTrackingMode:RPTrackingModeStandard];

Get tracking mode

Returns the tracking mode used by the SDK for both automatically and manually started tracking sessions. This value determines whether SDK-triggered tracking sessions run in .standard or .persistent mode. The default value is .standard.

let trackingMode = RPEntry.instance.getTrackingMode()
RPTrackingMode trackingMode = [[RPEntry instance] getTrackingMode];

Get SDK states

Get device ID registration state

Returns the latest known device identifier registration state.

Use this method to inspect whether the SDK has determined if the current device identifier is registered. The returned state includes both the registration status and the timestamp of the last check. A checkedAt value of 0 means the status has not been checked yet.

RPDeviceIdRegistrationState contains:

  • status - the latest known registration status.
  • checkedAt - the Unix timestamp, in seconds, when the registration status was last checked.

Available RPDeviceIdRegistrationStatus values: .notSet, .unknown, .registered, .notRegistered.

let deviceIdRegistrationState = RPEntry.instance.getDeviceIdRegistrationState()
RPDeviceIdRegistrationState *deviceIdRegistrationState = [[RPEntry instance] getDeviceIdRegistrationState];

Get tracking state

Returns the current tracking state of the SDK.

Use this method to asynchronously inspect whether tracking is currently available or unavailable. The result is delivered through the completion handler after the coordinator resolves the latest state.

RPTrackingState contains:

  • automaticTrackingStatus - status for automatic tracking.
  • manualTrackingStatus - status for manual tracking.

Available RPTrackingStatus values: .enabled, .deviceIdNotSet, .sdkDisabled, .disabledBySettings, .disabledByServer, .disabledBySchedule.

RPEntry.instance.getTrackingState { state in
    // Handle current tracking state
}
[[RPEntry instance] getTrackingStateWithCompletion:^(RPTrackingState * _Nonnull state) {
    // Handle current tracking state
}];

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(false)
[[RPEntry instance] setAggressiveHeartbeats:NO];

Check state

Example:

RPEntry.instance.isAggressiveHeartbeats()
[[RPEntry instance] isAggressiveHeartbeats];

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.setAccidentDetectionEnabled(true)
[[RPEntry instance] setAccidentDetectionEnabled:YES];

Change Accident detection sensitivity.


Accident detection sensitivity is normal by default. You can change sensitivity. Sensitivity options which is available to apply: .normal, .sensitive, .tough

RPEntry.instance.setAccidentDetectionSensitivity(sensitivity: .normal)
[[RPEntry instance] setAccidentDetectionSensitivityWithSensitivity:RPAccidentDetectionSensitivityNormal];

Tags


📘

The detailed information about using Tags is available here

Get a list of trips


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

Get trip details


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

Change a Transportation type


RPEntry.instance.api.changeTrackOrigin(.originalDriver, forTrackToken: "SELECTED_TRACK_TOKEN") { code, error in
            
}

//Avilable origins:
//.originalDriver
//.bus
//.motorcycle
//.other
//.passenger
//.running
//.taxi
//.train
//.walking
[[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

Upload unsent trips

RPEntry.instance.uploadUnsentTrips()
[[RPEntry instance] uploadUnsentTrips];

Get unsent trips

RPEntry.instance.getUnsentTripCount { unsentTripsCount in
  print("unsent trips count - \(unsentTripsCount)")        
}
[[RPEntry instance] getUnsentTripCountWithCompletion:^(NSInteger unsentTripsCount) {
   NSLog(@"unsent trips count - %ld", (long)unsentTripsCount);   
}];

Send a custom heartbeat

RPEntry.instance.sendCustomHeartbeat("CustomHeartbeat")
[[RPEntry instance] sendCustomHeartbeat:@"CustomHeartbeat"];