React Native
React Native HyperTrack SDK is a wrapper around native iOS and Android SDKs that allows to integrate them into React Native apps.
Requirements
Basic integration
Updating the SDK? Check out our CHANGELOG to see what's changed.
Add HyperTrack SDK to your project
npm install hypertrack-sdk-react-native \
hypertrack-sdk-react-native-plugin-android-location-services-google \
hypertrack-sdk-react-native-plugin-android-activity-service-google \
hypertrack-sdk-react-native-plugin-android-push-service-firebase⚠️
The plugins must have the same version as the main SDK dependency
Android
Set up HyperTrack repository
Add the repository to your project Gradle config (android/build.gradle)
Set up HyperTrack Maven repository in Gradle
Configure Proguard
iOS
Install HyperTrack SDK pod
The native iOS SDK is distributed using CocoaPods dependency manager.
Run pod install in your project's ios directory.
Enable Background Modes
Add purpose strings
Set up silent push notifications
Set the publishable key
Get your publishable key from the Setup page.
Grant the permissions to the app
Set Worker Handle
To link a Worker with the device you should set the worker handle:
HyperTrack.setWorkerHandle("user_id") // unique user identifierSee Worker Setup guide for more information.
Start tracking
Now the app is ready to be tracked from the cloud.
Follow the Track Work tutorial to learn how to control worker tracking from your backend (use the worker handle you set above).
Dashboard
Once your app is running, go to the dashboard where you can see a list of all your devices and their live location with ongoing activity on the map.
Recommended additional steps
Remind workers to reopen the app on iOS
If a worker swipes up on your app’s preview in the App Switcher, tracking can stop. The HyperTrack SDK can remind them to reopen your app. Once they do, tracking can resume in the background, even if they switch apps or lock the screen.
When the worker is on the way to a scheduled job, your dispatchers can use the updated ETA to spot a potential delay. Reopening the app sooner also gives your operations team a more complete record of the worker’s route and stops.
When the worker swipes the app away, the SDK can schedule a local notification if tracking is enabled, the worker is marked available, or they have an ongoing order. Your app needs the worker’s permission to show alerts, even if you already set up silent push notifications.
The reminder is off by default and requires hypertrack-sdk-react-native 14.3.0 or later. If you use Expo Prebuild, enable the reminder and customize its text in the Expo plugin options.
If you manage your iOS project directly, add this entry to your app target’s Info.plist and rebuild your iOS app.
<key>HyperTrackAppTerminationNotification</key>
<true/>To change the reminder text, set the optional title or body in the same Info.plist. See the configuration reference.
Identify devices
You can tag devices with names that will make it easy to distinguish them on HyperTrack Dashboard.
HyperTrack.setName("Device name")You can additionaly tag devices with custom metadata (and filter them in the Dashboard using metadata fields). Metadata should be representable in JSON.
HyperTrack.setMetadata({"key": "value"})Handle errors
Use the getErrors() or subscribeToErrors() to make sure that when the driver navigates to the screen where tracking is supposed to happen, there are no blockers that can prevent that.
You can use subscription API to be able to react immediately when errors come up:
import HyperTrack, { HyperTrackError } from 'hypertrack-sdk-react-native';
function handleErrors(errors) {
errors.forEach((error) => {
switch (error) {
case HyperTrackError.permissionsLocationDenied:
// Ask the worker to grant location permissions.
break;
case HyperTrackError.locationServicesDisabled:
// Ask the worker to enable location services.
break;
default:
// Handle other errors listed in the SDK reference.
break;
}
});
}
HyperTrack.getErrors().then(handleErrors);
const errorsSubscription = HyperTrack.subscribeToErrors(handleErrors);
// When the screen/model stops observing: errorsSubscription.remove();See Error API reference for a full list of errors.
Reference
For a full SDK API reference see HyperTrack React Native SDK Reference
SDK integration examples
To learn more about SDK integration examples, you may visit these resources:
Support
Email help@hypertrack.com.