HyperTrack iOS SDK Setup

To use the HyperTrack SDK on iOS you we first need to setup the SDK into our environment.

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

Step 1: Install the SDK

The HyperTrack SDK is available via CocoaPods. Add the following lines to your Podfile to install the SDK.

In case you haven't setup CocoaPods for your app, refer to their website and setup a Podfile, and then add these lines.

For Xcode 9


target 'AppName' do
   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.2'

        Dir.glob('Pods/SQLite.swift/Sources/SQLite/**/*.swift').each { |path|
                text = File.read(path)
                text = text.gsub(/import CSQLite/, 'import SQLite3')
                File.open(path, 'w') { |file| file.puts text }
                rescue Exception
                puts "Unable to patch #{path}: #{$!}"

For Xcode 8


target 'AppName' do
   pod 'HyperTrack', '0.4.56'

Now run pod install from the command line.

[info] Minimum Deployment target

HyperTrack SDK support iOS 9.0 and above as deployment targets.

[warning] Xcode project

Remember to use the .xcworkspace file to open your project in Xcode, instead of the .xcodeproj file, from here on.

[warning] Using Xcode 9

If you are using Xcode 9, then you might face compilation issues related to zlib and Sqlite. To resolve them, follow the steps mentioned here.

Step 2: Configure the SDK

Now that the SDK has been installed, you can use the SDK methods inside Xcode. Configure your publishable key and initialise the SDK.

import HyperTrack


[warning] Objective C config

In case your app is in Objective C, edit the Build Settings of the Pods Project. Change the Use Legacy Swift Language Version flag from Unspecified to No for “Alamofire” and “HyperTrack” libraries.

@import HyperTrack;

[HyperTrack initialize:@"YOUR_PUBLISHABLE_KEY"];

Step 3: Capabilities and permissions

Add background capabilities

Go to the capabilities tab in your app settings, scroll to background modes and switch it on. Select "Location updates", "Background fetch" and "Remote notifications".

Add permission strings to your Info.plist

Go to the Info tab in your app settings and add permission strings for

* Privacy - Location Always Usage Description
* Privacy - Motion Usage Description
* Privacy - Location Always and When In Use Usage Description
* Privacy - Location When In Use Usage Description

Configure Location & Motion usage permissions

The SDK is only compatible with the Location - Always and Motion Usage permissions. You can use the included utility methods to request permission, in case you feel the need to.

HyperTrack.requestAlwaysLocationAuthorization { (authorized) in
  //handle authorization status, if needed
[HyperTrack requestAlwaysLocationAuthorizationWithCompletionHandler:^(BOOL authorized) {
  //handle authorization status, if needed
[HyperTrack requestMotionAuthorization];

Step 4: 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: name, phone: phone, uniqueId: phone) { (user, error) in
  if (error != nil) {
    // Handle getOrCreateUser API error here

  if (user != nil) {
    // Handle getOrCreateUser API success here
[HyperTrack getOrCreateUserWithName:name phone:phone uniqueId:uniqueId 
  completionHandler:^(HTUser * _Nullable user, HTError * _Nullable error) {
  if (user) {
  // Handle getOrCreateUser API success here
  } else {
    // Handle createUser error here, if required

Step 5: Start the SDK

To start tracking the user, use the resumeTracking 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.pauseTracking() method.

[HyperTrack resumeTracking];

Step 6: 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.

[success] SDK Setup Completed

Now that we have the basic integration complete, we need to implement the device-server communication.

Stop the SDK

To stop tracking the user, use the pauseTracking method.

[HyperTrack pauseTracking];

results matching ""

    No results matching ""