Installing the SDK

This guide will help you setup the React Native module in your application. 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.

In case you are not using React Native, you can refer to the iOS or Android versions. If you're looking for an example integration, use the example react native application.

[info] Step-By-Step Onboarding

Setting up HyperTrack React Native SDK in your app?

We recommend you try our new interactive step-by-step onboarding

React Native Onboarding

Step 1: Install the dependency

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

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

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

Step 2: Setup dependencies

Android

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.

[warning] Issues with Android dependencies

Refer here for detailed info.

allprojects {
    repositories {
        ...
        maven { url 'http://hypertrack-android-sdk.s3-website-us-west-2.amazonaws.com/' }
    }
}

iOS

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

  2. Edit the Podfile to include HyperTrack as a dependency for your project, and then install the pod.

  3. Now, open the iOS project with the .xcworkspace file in Xcode, and add the HyperTrack.framework file to the linked frameworks and libraries section if they are not already added by Cocoapods.

$ cd ios
$ pod init
# ios/Podfile
target 'AppName' do
  use_frameworks!

  # Pods for AppName
  pod 'HyperTrack'

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['SWIFT_VERSION'] = '3.0'
      end
    end
  end
end

Manual linking on iOS

After the Cocoapods are setup, we need to manually link the wrapper code.

  1. Open the iOS project with .xcworkspace file in Xcode.

  2. Move the ios/RNHyperTrack.h and ios/RNHyperTrack.m files to your project.

Linking on iOS

Step 3: 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_PUBLISHABLE_KEY');
  }
}

Step 4: Native capabilities

Follow these steps to setup native capabilities for iOS and Android.

Step 5: Request for Permissions & Location Services

For Android, The SDK requires Location Permission to be granted and Location Services to be enabled in High Accuracy.

For iOS, The SDK requires Location & Motion Authorizations to be granted and Location Services to be enabled.

For more details, refer to our section on permissions & location services APIs.

// Call this method to check location authorization status.
RNHyperTrack.locationAuthorizationStatus((callback) => {
  // Handle locationAuthorizationStatus API callback here
  console.log('locationAuthorizationStatus: ', callback);
});

// Call this method to request Location Authorization for Android & iOS (Always Authorization).
// NOTE: In Android, the Permission dialog box's title and message can be customized by passing them as parameters.
RNHyperTrack.requestLocationAuthorization(title, message);

// Call this method to check location services are enabled or not.
RNHyperTrack.locationServicesEnabled((callback) => {
  // Handle locationServicesEnabled API callback here
  console.log('locationServicesEnabled: ', callback);
});

// Call this method to check if Motion Activity API is available on the device
// NOTE: Motion Authorization is required only for iOS. This API will return an error in Android.
RNHyperTrack.canAskMotionPermissions((callback) => {
  // Handle canAskMotionPermissions API callback here
  console.log('canAskMotionPermissions: ', callback);
});

// Call this method to request Motion Authorization for iOS.
// NOTE: Motion Authorization is required only for iOS. This API will return an error in Android.
RNHyperTrack.requestMotionAuthorization();

results matching ""

    No results matching ""