Basic integrations with the HyperTrack iOS SDK

Once you have the iOS SDK installed you will need to integrate into your application and begin using. You'll begin to see trips that the user made along with polylines, time & distance traveled, and places that the user stopped at along with time they spent at that place.

In case you are not using iOS, you can refer to the Android version, or the React Native version.

Step 1: Create SDK user

To be able to identify the device, the SDK needs a user id. You can create a new user user on the SDK, and specify a string identifier. This is a network call that requires the device to be online.

[info] User already created?

You can set an existing user id, in case you have created an user id via the backend API using the HyperTrack.setUserId("YOUR_USER_ID") method in the SDK.

HyperTrack.getOrCreateUser(name, _phone: phoneNumber, lookupID) { (user, error) in
  if (error != nil) {
    // Handle getOrCreateUser API error here
    ...
    return
  }

  if (user != nil) {
    // Handle getOrCreateUser API success here
    ...
  }
}
[HyperTrack getOrCreateUser:name _phone:phoneNumber :lookupId 
    completionHandler:^(HyperTrackUser * _Nullable user, HyperTrackError * _Nullable error) {
  if (user) {
  // Handle createUser success here, if required
  // HyperTrack SDK auto-configures UserId on createUser API call,
  // so no need to call [HyperTrack setUserId:@"USER_ID"] API

  // On UserLogin success
  [self onUserLoginSuccess];

  } else {
    // Handle createUser error here, if required
    ...
  }
}];

Step 2: Start the SDK

To start tracking the user, use the startTracking method. You can keep the SDK on throughout the day, or turn it off if you want to stop tracking the user at any point of time using the HyperTrack.stopTracking() method.

HyperTrack.startTracking()
[HyperTrack startTracking];

Step 3: View dashboard

Install your app with the HyperTrack SDK on a device and begin tracking on the Dashboard. You would see the user’s current state on the HyperTrack dashboard. If you click on the user, you should be able to view the user's trips and stops.

Step 4: Stop the SDK

To stop tracking the user, use the stopTracking method.

HyperTrack.stopTracking()
[HyperTrack stopTracking];

Simulate a trip for testing

To simulate a trip, replace startTracking API with startMockTracking and stopTracking API with stopMockTracking. This will run a simulation from your location to a nearby location. You can stop this simulation anytime by calling stopMockTracking API.

results matching ""

    No results matching ""