App link: https://github.com/hypertrack/react-native-sdk-onboarding
Compatibility The module works with React Native 0.41.+
In your project directory, run the bash commands to install the React Native module and link it to your project files.
npm install react-native-hypertrack --save
react-native link react-native-hypertrack- Upgrade compileSdkVersion, buildToolsVersion, support library version
For the Android SDK, edit the
build.gradlefile in yourandroid/appdirectory
-
https://github.com/hypertrack/react-native-sdk-onboarding/blob/master/android/app/build.gradle
-
L86, L87, L131
android { compileSdkVersion 26 buildToolsVersion "26.0.3" ... }dependencies { ... compile project(':react-native-hypertrack') compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:26.1.0" compile "com.facebook.react:react-native:+" // From node_modules ... }
-
Adds maven dependency for Google Libraries For the Android SDK, edit the
build.gradlefile in yourandroiddirectory// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() maven { url 'https://maven.google.com/' name 'Google' } } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.1.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } maven { url 'https://maven.google.com/' name 'Google' } } }
Configure your publishable key and initialise the SDK in the constructor method of your Component class. This needs to be done only once in the app lifecycle.
Account keys Sign up to get account keys if you haven't already.
The SDK needs a User object to identify the device. The SDK has a convenience method getOrCreateUser() to lookup an existing user using a unique identifier (called lookupId) or create one if necessary.
Method parameters
- userName - Name of the user entity
- phone - Phone number of the user entity
- lookupId - Unique identifier for your user
Use this API in conjunction to your app's login flow, and call getOrCreate at the end of a successful login flow. This API is a network call, and needs to be done only once in the user session lifecycle.
Waiting for your app to run
Use the startTracking() method to start tracking. Once the user starts tracking, you can see Trips and Stops of the user.
This is a non-blocking API call, and will also work when the device is offline.
Waiting for your app to run
View on the dashboard View the user's trips and stops here.
Use the stopTracking() method to stop tracking. This can be done when the user logs out.
Ready to deploy! Your React Native app is all set to be deployed. As your users update and log in, their live location will be visualized on this dashboard.
- Add team members to the HyperTrack dashboard
- Follow one of our use-case tutorials to build your live location feature