Telematics SDK | Developer portal
  • Get started
  • 4 Steps to Integrate SDK
  • Product Wiki
  • License
  • FAQ
  • PRODUCT DESCRIPTION
    • How it works
    • SDK Features
    • Scoring
      • Risk driving Scoring
        • Event detection
        • Trip rating
        • Overall scoring
      • Eco Scoring
    • Dataset
      • Dataset | User statistics API
      • Data samples
        • Summary - Processed track details (Rich track details)
        • Processed track waypoints (Rich track points)
        • Summary - list of Processed tracks
        • Incoming track events
        • Incoming track points (waypoints)
        • Summary - list of Incoming tracks
      • Dataset Decription
        • Bluetooth OBD - Vehicle Dataset
        • LastKnownPoints
        • IncomingTrackPoints
        • IncomingTrackEvents
        • Enriched telematics data
          • RichTracks
          • RichTrackPoints
          • RichTrackEvents
          • RichTrackDetails
          • UserStatisticDrivingDetails
        • Raw telematics data from SDK
    • Reporting
      • Drivecoins summary
      • Trip summary
      • Scoring summary
      • User state
      • Fraud
      • Trip waypoints
      • Trip events
    • External Articles
      • Why mobile telematics hits hardware telematics
  • Step 1: Create Datahub Account
  • Step 2: SDK Installation
    • Get started
    • iOS SDK installation
      • *Set up Your Development Environment
      • *Configure Your Project
      • *App Delegate
      • *Configure Framework
      • *React Native Installation
        • Create the iOS bridge
      • Add list of trips to your ViewController
      • Add statistics data to your ViewController
      • *What’s different in iOS 13?
      • *iOS 13 Permissions Wizard
      • *SDK Enable \ Disable \ Disable With Upload
      • *Incoming Tags
      • *Tracking Status
      • *SDK Delegates
      • *SDK Modes
      • *Using the Debugging Tools in Simulator
    • Android SDK installation
      • *Getting started
        • *Set up Your Development Environment
        • *Setup and enable SDK
        • *Permissions wizard
        • *Permissions dialog
        • *Configure SDK variables for notifications
      • *Subscribe to tracking events
      • *Incoming tags managing
      • *Migration from SDK v1.6.x to SDK v2.0.x
    • *Check SDK Installation
      • iOS Simulator
      • DataTool
      • ZenRoad
    • *Demo Applications
      • iOS | Open Source Demo Application
      • iOS | SDK Demo Application
      • iOS | Swift | SDK Demo Application
      • Android | SDK Demo Application
      • Android | Java | SDK Demo Application
      • Flutter | SDK Demo Application
    • SDK Changelog
      • Android SDK Changelog
      • iOS SDK Changelog
    • Permissions Guides
      • First Launch
        • iOS 13 (and higher) Permissions Guide
        • iOS 12 (and lower) Permissions Guide
        • Android 9 Permissions Guide
        • Android 9 XIaomi Permissions Guide
        • Android 10 Permissions Guide
      • *Troubleshooting
        • iOS — Troubleshooting
          • iOS — Troubleshooting
        • Android — Troubleshooting
          • Samsung — Troubleshooting
          • Oppo — Troubleshooting
          • Huawei — Troubleshooting
          • Xiaomi — Troubleshotting
          • OnePlus — Troubleshooting
          • Meizu — Troubleshooting
          • Asus — Troubleshooting
          • Vivo — Troubleshooting
          • Wiko — Troubleshooting
  • Step 3: Register SDK users
    • User Registration (API)
  • Step 4: API | User Statistics, Scores, Trips
    • Step 4: Get Statistics, Scorings and Trip Data
    • API Authorization
    • Statistics and Scoring APIs
      • Get started - Statistics and Scoring API
      • User | Individual Scorings and Statistics
      • Admin | User(s) - Scorings and Statistics
      • Admin | Consolidated Scorings and Statistics
    • Trips API
      • Get a short list of tracks
      • Get a list of tracks with paging
      • Get a list of tracks by IDs
      • Get a single track with waypoints
      • Get the most earliest track
      • Track Statuses
  • SDK Features
    • *Bluetooth Device - Get started
      • *Get Started
      • *Android - ELM API
      • *iOS - ELM API
    • Trip Tags - Get started
      • Tags for trips via mobile app
        • Android - Tags for trips
        • iOS - Tags for trips
      • Tags for period
      • Trip log by tags
  • PLATFORM FEATURES
    • *User Management
      • *User Registration
      • *Check User Existence
      • *User Management
    • *Vehicle Management
      • *Directories
      • *Vehicles
    • FNOL, Inspections & Damage Recognition
      • Get started
      • Profiles
      • Claims
      • Vehicle inspections
        • Dictionary of vehicle photos
      • Photo processing
    • *Leaderboard
      • *Summary Leaderboard
      • *Leaderboard by factors
      • Swagger - Leaderboard
    • *Streaks
    • *SNS
      • *How to register AWS SNS
    • 3rd party data processing
      • Swagger - Incoming getaway
    • *User & Permissions Status | Heartbeats
  • Other
    • Response Codes
    • Resources swaggers
      • Swagger: User service
      • Swagger: Scorings and Statistics API
      • Swagger: Telematics data
      • Swagger: Leaderboard
      • Swagger: Vehicle Management
      • Driving details
      • Swagger: FNOL, Inspections & Damage Recognition
      • Swagger: Heartbeats
    • Archive
      • Get started
      • Statistics and Scorings API
      • Step 5: Get statistics and trip data [ARCHIVED]
      • User Statistics API [Archived]
      • SDK - Statistics API [ARCHIVED]
        • Get the data to the Android app
          • Android Telematics data (Tracks)
            • Check current running track state
            • Get start date for current recording trip
            • Register tracking state listener (for onStartTracking/onStopTracking events)
            • Register speed violations listener
            • Get flag for registered speed violations listener
            • Get registered speed limit in km/h or default
            • Get registered speed violations timeout in ms or default
            • Get Tracks
            • Get detailed trips information
            • Get available user roles
            • Change a user role (any of TrackOriginDictionary.code)
          • Android User Statistics
            • Get Dashboard info
            • Get detailed Dashboard
            • Get Driving time statistics
            • Get Speeding statistics
            • Get Mileage statistics
            • Get Distracted Phone Usage statistics
        • Get the data to the iOS app
          • Other methods
          • iOS Telematics data (tracks)
            • Request all Tracks with specified offset and limit
            • Request all Tracks with specified offset and limit. No filter will be used in request
            • Request Track info with specified Track Token
            • Request Track origins dictionary
            • Change Track Origin Code
            • Share Track
          • iOS User Statistics
            • Get shared Track
            • Request main statistics data for all possible statistic types
            • NS_ENUM
            • Request main statistics data for all possible statistic types
            • Properties and Protocols
      • Get all DeviceTokens
    • Report a bug
    • Data Hub
    • Talk to sales
  • Postman collection
Powered by GitBook
On this page
  • Step 1 - BridgeClassDemo.h
  • Step 2 - DemoClass.m
  • Step 3 - AppDelegate
  • Step 4 - React Native side

Was this helpful?

  1. Step 2: SDK Installation
  2. iOS SDK installation
  3. *React Native Installation

Create the iOS bridge

Create the native files for your module by opening your workspace file on Xcode, select your project, and right-click to add a new file. Select Cocoa Touch Class, give the name, and create it.

Step 1 - BridgeClassDemo.h

Create the bridge by copying the code below into your BridgeClassDemo.h file

BridgeClassDemo.h
//
//  BridgeClassDemo.h
//  RaxelPulseReactNativeDemo
//
//  Created by Sergey Emelyanov on 19/04/2020.
//  Copyright © 2020 Data motion Pte.Ltd. All rights reserved.
//  https://telematicssdk.com

#import "React/RCTBridgeModule.h"

// Instead of BridgeClassDemo put the name of your module
@interface BridgeClassDemo : NSObject <RCTBridgeModule>
@end

Step 2 - DemoClass.m

Add the code below into your DemoClass.m file:

DemoClass.m
//
//  BridgeClassDemo.m
//  RaxelPulseReactNativeDemo
//
//  Created by Sergey Emelyanov on 19/04/2020.
//  Copyright © 2020 Data motion Pte.Ltd. All rights reserved.
//  https://telematicssdk.com

#import <React/RCTLog.h>
#import <RaxelPulse/RaxelPulse.h>
#import <AdSupport/AdSupport.h>
#import "BridgeClassDemo.h" // Here put the name of your module

@implementation BridgeClassDemo // Here put the name of your module

// This RCT (React) "macro" exposes the current module to JavaScript

RCT_EXPORT_MODULE(BridgeClassDemo);

RCT_EXPORT_METHOD(start:(NSString *)token) {
  dispatch_async(dispatch_get_main_queue(), ^{
    [RPEntry instance].virtualDeviceToken = @"DeviceToken";
    [RPEntry instance].disableTracking = NO;
  });
}

RCT_EXPORT_METHOD(enableSDK) {
  dispatch_async(dispatch_get_main_queue(), ^{
      [[RPEntry instance] setEnableSdk: true];
  });
}

RCT_EXPORT_METHOD(disableSDK) {
  dispatch_async(dispatch_get_main_queue(), ^{
      [[RPEntry instance] setDisableWithUpload];
  });
}

/** You can add any required methods by yourself 
* using this code as a template

RCT_EXPORT_METHOD(yourmetod) {
  dispatch_async(dispatch_get_main_queue(), ^{
      //Your native command
  });
}

*/

@end

Step 3 - AppDelegate

Handle library methods for AppDelegate as it is in the example below:

#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTRootView.h>
#import <RaxelPulse/RaxelPulse.h>
#import <React/RCTLog.h>
#import <AdSupport/AdSupport.h>

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[RPCPermissionsWizard returnInstance] launchWithFinish:^(BOOL showWizzard) {
    [RPEntry initializeWithRequestingPermissions:YES];
  }];
  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
    moduleName:@"RCdemo_mobile"
    initialProperties:nil];
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;
}
  
- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(nonnull NSString *)identifier completionHandler:(nonnull void (^)(void))completionHandler {
  [RPEntry application:application handleEventsForBackgroundURLSession:identifier completionHandler:completionHandler];
}
  
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
  [RPEntry applicationDidReceiveMemoryWarning:application];
}
  
- (void)applicationWillTerminate:(UIApplication *)application {
  [RPEntry applicationWillTerminate:application];
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
  [RPEntry applicationDidEnterBackground:application];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
  [RPEntry applicationDidBecomeActive:application];
}

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
  [RPEntry application:application performFetchWithCompletionHandler:^{
    completionHandler(UIBackgroundFetchResultNewData);
  }];
}

@end

And that’s it for the native side.

Step 4 - React Native side

We can now call it anywhere on the React Native side:

import { NativeModules } from 'react-native';
var BridgeClassDemo = NativeModules.BridgeClassDemo;
//Let's show it
BridgeClassDemo.start(@"DeviceToken")
BridgeClassDemo.enableSDK()
BridgeClassDemo.disableSDK()
//BridgeClassDemo.yourmetod()
Previous*React Native InstallationNextAdd list of trips to your ViewController

Last updated 4 years ago

Was this helpful?