Basic integration

This guide will help you setup the React Native module in your application and configure it to be controlled via REST APIs. The module is built on top of native iOS and Android SDKs, which collect locations and related data in a battery efficient way. The module exposes methods to start and stop data collection, and interact with the HyperTrack APIs.

If you're looking for an example integration, use the example-react-native application.

Install the dependency

In your project directory, install and link the module package from npm.

$ npm install react-native-hypertrack --save
$ react-native link react-native-hypertrack

If you are using an older version of React Native that does not support link, you can manually link libraries.

Setup Android dependencies

To use the HyperTrack Android SDKs, the following urls need to be added to your android/build.gradle file. This will configure the repository urls for the SDKs.

allprojects {
    repositories {
        ...
        maven { url 'http://hypertrack-android-sdk.s3-website-us-west-2.amazonaws.com/' }
        maven { url 'https://repo.eclipse.org/content/repositories/paho-releases/' }
    }
}

If you have some issues with Android, some common troubleshooting is available here.

Setup iOS dependencies

  1. The native iOS SDKs need to be setup using Cocoapods. In your project's ios directory, create a Podfile.

     $ cd ios
     $ pod init
    
  2. Edit the Podfile to include HTTransmitter as a dependency for your project, and then install the pod.

     $ cat Podfile
     target 'YourApp' do
       pod 'HTTransmitter'
     end
    
     $ pod install
    
  3. Now, open the iOS project with the .xcworkspace file in Xcode, and add the native SDK .a files in the linked frameworks and libraries section. You need to add libHTTransmitter.a, libHTCommon.a, libMQTTClient.a.

Configure the API key

To configure the SDK, set the publishable key. This can be done in the constructor of your component class.

import RNHyperTrack from 'react-native-hypertrack';

export default class MyApp extends Component {
  constructor() {
    super();
    // Initialize HyperTrack wrapper
    RNHyperTrack.initialize('YOUR_PK_TOKEN');
  }
}

Connect the SDK

Initialise the SDK connection to the server by passing the driver id to the connectDriver method.

[info] Driver entity

If you don't have a driver id, refer to creating a Driver.

RNHyperTrack.connectDriver('YOUR_DRIVER_ID');

Once the SDK has been connected, it is ready to be controlled by the REST APIs.

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""