React native module for hypertrack-android and hypertrack-ios SDKs. Methods in the Driver SDK are covered in the current release. The example-react-native app is built on top of this module.
The v1.x wrapper is built for HyperTrack v3, and will not work with the older SDKs. There will be breaking changes if you are upgrading - please refer to docs.hypertrack.com.
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.
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 here.
-
The native iOS SDKs need to be setup using Cocoapods. In your project's
ios
directory, create a Podfile.$ cd ios $ pod init
-
Edit the Podfile to include
HyperTrack
as a dependency for your project, and then install the pod withpod install
.use_frameworks! platform :ios, '9.0' target 'AwesomeProject' do pod 'HyperTrack' end
-
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.
import RNHyperTrack from 'react-native-hypertrack';
...
export default class MyApp extends Component {
constructor() {
super();
// Initialize HyperTrack wrapper
RNHyperTrack.initialize("YOUR_PUBLISHABLE_KEY");
}
}
...
If you have a user that is to be associated with this device, set the user id.
RNHyperTrack.setUserId("YOUR_USER_ID");
In case you do not have a user, you can create a new user. Calling this will automatically set the user in the SDK.
RNHyperTrack.createUser("USER_NAME", (success) => {}, (error) => {});
To start tracking on the SDK, use the following method.
RNHyperTrack.startTracking((success) => {}, (error) => {});
To stop tracking on the SDK, use the following method.
RNHyperTrack.stopTracking();
If you are using actions for your use-case, you can complete actions through the SDK.
RNHyperTrack.completeAction("YOUR_ACTION_ID");
The HyperTrack documentation is at docs.hypertrack.com.
For any questions, please reach out to us on Slack or on [email protected]. Please create an issue for bugs or feature requests.
Thanks to react-native-create-library which saved a few hours.