Utility methods

Last updated 11 days ago

Repository of all the available SDK methods in the Movement SDK for iOS

Initializing the SDK

Initialize the HyperTrack SDK by calling this method once from didFinishLaunchingWithOptions method in the AppDelegate class of your Application.

Swift
Objective-C
AppDelegate.swift
HyperTrackCore.initialize(publishableKey: PUBLISHABLE-KEY) { [weak self] (error) in
/// perform post initialization actions
/// handle error if any
}
AppDelegate.m
[HTCore initializeWithPublishableKey:@"PUBLISHABLE-KEY" completionHandler:^(HTCoreError * _Nullable error) {
/// perform post initialization actions
/// handle error if any
}];

Parameters

Name

Type

Description

publishableKey

String

A unique String that is used to identify your account with HyperTrack

completionHandler

Block

A callback which takes an optional CoreError as a parameter and returns Void. Use this handler to determine if there were any issues while initializing the SDK.

Check location permission

Check whether your app has location permission.

Swift
Objective-C
HyperTrack.checkLocationPermission()
[HTCore checkLocationPermission];

Returns

Type

Description

Bool

true if the location permission has been granted, false otherwise

Request location permission

Request permission to track user's location.

Swift
Objective-C
HyperTrackCore.requestLocationPermission { (error) in
/// handle error if any
}
[HTCore requestLocationPermissionWithCompletionHandler:^(HTCoreError * _Nullable error) {
/// handle error if any
}];

Parameter

Name

Type

Description

completionHandler

Block

A callback which takes an optional CoreError as a parameter and returns Void. Use this handler to determine whether the user has provided the required location permissions or not.

Check activity permission

Check whether your app has activity (Motion) permission.

Swift
Objective-C
HyperTrack.checkActivityPermission()
[HTCore checkActivityPermission];

Returns

Type

Description

Bool

true if the location services are ON, false otherwise

Request activity permission

Request permission to track user's activities.

Swift
Objective-C
HyperTrackCore.requestActivityPermission { (error) in
/// handle error if any
}
[HTCore requestActivityPermissionWithCompletionHandler:^(HTCoreError * _Nullable error) {
/// handle error if any
}];

Parameters

Name

Type

Description

completionHandler

Block

A callback which takes an optional CoreError as a parameter and returns Void. Use this handler to determine whether the user has provided the required motion permissions or not.

Pause tracking

Stops the SDK from listening to user's movement updates and recording any data. If this method is called, the SDK will not resume movement tracking until resumeTracking() method is called.

Swift
Objective-C
HyperTrackCore.pauseTracking()
[HTCore pauseTracking];

Resume tracking

Allows the SDK to resume a previously paused tracking. Call this method when you had previously made a call to pauseTracking() method. While setting up the SDK, you don't need to explicitly call this method. The SDK will automatically start recording data as soon as it receives the required permissions.

Swift
Objective-C
HyperTrackCore.resumeTracking()
[HTCore resumeTracking];

Get device id

Get device id generated by HyperTrack for this device. You may want to map this device id to the user id in your system, and send this mapping to your server.

Swift
Objective-C
let deviceId = HyperTrackCore.getDeviceId()
NSString * deviceId = [HTCore getDeviceId];

Returns

Type

Description

String

A unique identifier for the device.

Add device name & metadata

Add/edit a name and metadata to deviceID. Helps you identify the device on HyperTrack dashboard.

Swift
Objective C
let name = "Alex"
let metaData : [String : Any] = ["customer_id" : 505054, "vehicle" : "car"]
HyperTrackCore.setDevice(forName: name, metaData: metaData) { [weak self] (error) in
/// handle error if any
}

NSString *name = @"Alex";
NSDictionary *metaDict = [NSDictionary dictionaryWithObjects:@[@505054,"car"]
forKeys:@[@"customer_id", "vehicle"]];
[HTCore setDeviceForName: name metaData:metaDict completionHandler:^(HTCoreError * _Nullable error) {
/// handle error if any
}];

Name

Type

Description

name

String

Name that you want to see on the HyperTrack dashboard. Could be name of the user

metadata

Dictionary

Dictionary of type <String, Any>. Use this to send extra information.

completionHandler

Block

A callback which takes an optional CoreError as a parameter and returns Void. Use this handler to determine if there is any error while setting device name.

Request location updates

Your application can register for location updates by implementing LocationUpdateDelegateand calling the below method.

Swift
Objective-C
HyperTrackCore.setLocationUpdatesDelegate(self)
[HTCore setLocationUpdatesDelegate:self];

Parameters

Type

Description

LocationUpdateDelegate

A delegate which implements LocationUpdateDelegate. The SDK will call locationUpdates(...) when new locations are received from the CLLocationManager.

Enable & disable logging

HyperTrack SDK does extensive logging to help developers with debugging. Call the below methods to enable or disable logging. Note that logging is disabled by default.

Swift
Objective-C
HyperTrackCore.enableLogging()
HyperTrackCore.disableLogging()
[HTCore enableLogging];
[HTCore disableLogging];