HyperTrack Class Method Reference

HyperTrack class defines a set of API methods.

Summary

Method Description
initialize Initializes HyperTrack SDKs with your Account's PublishableKey.
getPublishableKey Returns the PublishableKey currently configured in the SDK.
resumeTracking Enables tracking to be started when actions are assigned to the user. Call this method after you have force paused by calling pauseTracking.
getUserId Returns the currently configured UserID.
isTracking Call this method to check if the user is active currently i.e. there are pending action for a configured user.
getCurrentLocation Call this method to get the user's current location. This method will return nil of the location services are off or the app doesn't have required permissions.
getCurrentLocation(completionHandler: ...) Call this method to fetch user's current location. The completionHandler will provide an error if location services are off or the app doesn't have required permissions.
getOrCreateUser Call this method to get or create a User on HyperTrack API Server for the current device with given UniqueId.
updateUser Call this method to update a User's details on HyperTrack API Server for the current user id configured on the sdk.
createAction Call this method to create an Action to the configured user.
getActionFor(actionId: String, ...) Fetches the details of an action associated with the actionId.
getActionFor(collectionId: String, ...) Fetches a list actions associated with the collectionId.
getActionsFor(uniqueId: String, ...) Fetches the details of an action associated with the uniqueId.
getActionsFor(shortCode: String, ...) Fetches the details of an action for a given shortCode (unique code in Action's trackingUrl)
trackActionFor(actionId: String, ...) Fetches the tracking details of an action associated with the actionId.
trackActionFor(collectionId: String, ...) Fetches a list tracking details for actions associated with the collectionId.
trackActionsFor(uniqueId: String, ...) Fetches the tracking details of an action associated with the uniqueId.
trackActionsFor(shortCode: String, ...) Fetches the tracking details of an action for a given shortCode (unique code in Action's trackingUrl)
completeAction Completes an action for a given actionId
completeActionInSync Completes an action for a given actionId synchronously with HyperTrack Server
completeActionWithUniqueIdInSync Complete an action for a given uniqueId synchronously with HyperTrack Server.
locationAuthorizationStatus Returns the app’s authorization status for using location services.
requestAlwaysLocationAuthorization Call this method to request the location always permission..
motionAuthorizationStatus Returns the app's authorization status for using motion sensors.
isActivityAvailable Returns a Boolean indicating whether motion data is available on the current device.
requestMotionAuthorization Call this method to request the motion permission.
locationServicesEnabled Returns a Boolean value indicating whether location services are enabled on the device.
requestLocationServices Launches the settings app and opens the privacy settings screen for your app.
registerForNotifications Register to receive remote notifications via Apple Push Notification service.
didRegisterForRemoteNotificationsWithDeviceToken Provide the deviceToken to HyperTrack upon successful registration with APNs
didFailToRegisterForRemoteNotificationsWithError Inform HyperTrack that the device registration with APNs has failed.
isHyperTrackNotification Returns a Boolean that indicates whether a push notification received on the device was sent by HyperTrack.
didReceiveRemoteNotification Provide the userInfo dictionary received as part of push notification to HyperTrack for processing.
getPlaceline Fetches the placeline of the user for a given date.
setGeofenceAtPlace Call this method to start monitoring for an entry in a given place.
getCurrentActivity Returns the last activity performed by the user.
getPendingActions Fetches a list of incomplete actions for the user.

Public Methods

initialize

Call this method to initialize HyperTrack SDKs with your Account's PublishableKey in the onCreate method of either your Application file or your app's Launcher activity. Refer to the HyperTrack API key.

class func initialize(_ publishableKey: String)
Parameter Description
publishableKey Pass your account's PublishableKey as a parameter
getOrCreateUser

Call this method to get or create a User on HyperTrack API Server for the current device with given unique Id.

class func getOrCreateUser(name: String, phone: String, _ uniqueId: String, completionHandler: @escaping (_ user: HTUser?, _ error: HTError?) -> Void)
Parameter Description
name Name of the user
phone E164 formatted phone number of the user
photo Base64 string of user image file OR URL of image
uniqueId A unique id that you can add to the user to search
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTUser? and HTError? as argument.
updateUser

Call this method to update a User's details on HyperTrack API Server for the current user id configured on the sdk.

class func updateUser(_ name: String, _ phone: String? = nil, _ uniqueId: String? = nil, _ photo: UIImage? = nil, _ completionHandler: @escaping (_ user: HTUser?, _ error: HTError?) -> Void)
Parameter Description
name Name of the user
phone E164 formatted phone number of the user
photo Base64 string of user image file OR URL of image
uniqueId A unique id that you can add to the user to search
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTUser? and HTError? as argument.
locationServicesEnabled

Call this method to check whether the user has granted location permission for the app.

class func locationServicesEnabled() -> Bool
Return Description
Bool Returns true if the location permission has been granted, false otherwise.
requestAlwaysLocationAuthorization

Call this method to request Location permission to power HyperTrack SDK.

class func requestAlwaysLocationAuthorization(completionHandler: @escaping (_ isAuthorized: Bool) -> Void)
Parameter Description
completionHandler A block object to be executed when the user selects one of the authorization options for location services. This block has no return value and takes a Bool which indicates whether the user chose to authorize location services or not.
requestLocationServices

Call this method to request user to enable Location Services to power HyperTrack SDK.

class func requestLocationServices()
getCurrentLocation

Call this method to fetch user's current location.

class func getCurrentLocation(completionHandler: @escaping (_ currentLocation: CLLocation?,
        _ error: HTError?) -> Void)
Parameter Description
completionHandler A block object to be executed if current location is available. This block has no return value and takes a tuple of CLLocation? and HTError? as argument.
class func getCurrentLocation() -> CLLocation?
Return Description
CLLocation? If available returns the current location of the device else returns nil.
isTracking

Check if the user is active currently i.e. User has some pending action.

class var isTracking: Bool
Return Description
Bool Returns true if the SDK is active for the configured user.
createAction

Call this method to create an Action for the current user.

class func createAction(_ actionParams: HTActionParams, _ completionHandler: @escaping (_ action: HTAction?, _ error: HTError?) -> Void)
Parameter Description
actionParams Pass HTActionParams which provides details required to create an action.
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.
getActionFor

Call this method to get Action details for a given actionId

class func getActionFor(actionId: String, completionHandler: @escaping (_ action: HTAction?, _ error: HTError?) -> Void)
Parameter Description
actionId Pass the id of an already created action
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.

Call this method to get a list of actions for a given collectionId

class func getActionsFor(collectionId: String, completionHandler: @escaping (_ action: [HTAction]?, _ error: HTError?) -> Void)
Parameter Description
collectionId Pass the collectionId of actions
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of array of HTAction and HTError? as argument.

Call this method to get the details of an action for a given uniqueId

class func getActionsFor(uniqueId: String, _ completionHandler: @escaping (_ action: [HTAction]?, _ error: HTError?) -> Void)
Parameter Description
uniqueId Pass the uniqueId of an action.
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.

Call this method to get a list of actions for a given shortCode (unique code in action's trackingUrl property)

class func getActionsFor(shortCode: String, _ completionHandler: @escaping (_ action: [HTAction]?, _ error: HTError?) -> Void)
Parameter Description
shortCode Pass the shortCode of actions
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of array of HTAction and HTError? as argument.
trackActionFor

Call this method to get tracking details for a given actionId

class func trackActionFor(actionId: String, completionHandler: @escaping (_ action: HTAction?, _ error: HTError?) -> Void)
Parameter Description
actionId Pass the id of an already created action
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.

Call this method to get a list of tracking details for a given collectionId

class func trackActionFor(collectionId: String, completionHandler: @escaping (_ action: [HTTrackAction]?, _ error: HTError?) -> Void)
Parameter Description
collectionId Pass the collectionId of actions
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of array of HTTrackAction and HTError? as argument.

Call this method to get tracking details for a given uniqueId

class func trackActionFor(uniqueId: String, _ completionHandler: @escaping (_ action: [HTAction]?, _ error: HTError?) -> Void)
Parameter Description
uniqueId Pass the uniqueId of an action.
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.

Call this method to get tracking details for a given shortCode (unique code in action's trackingUrl property)

class func trackActionFor(shortCode: String, completionHandler: ((_ action: HTAction?, _ error: HTError?) -> Void)? = nil)
Parameter Description
shortCode Pass the shortCode of actions
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.
completeAction

Call this method to mark an action as completed

class func completeAction(_ actionId: String)
Parameter Description
actionId Pass the action's id generated on HyperTrack Server
completeActionInSync

Call this method to mark an action complete synchronously with HyperTrack Server.

[info] Synchronous?

This API will make an HTTP call and will not be retried later in case of a failure.

class func completeActionInSync(_ actionId: String, completionHandler : @escaping HTActionCompletionHandler)
Parameter Description
actionId Pass the action's id generated on HyperTrack Server
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.
completeActionWithUniqueIdInSync

Call this method to mark an action complete synchronously with HyperTrack Server.

[info] Synchronous?

This API will make an HTTP call and will not be retried later in case of a failure.

class func completeActionWithUniqueIdInSync(_ uniqueId: String, completionHandler : @escaping HTActionCompletionHandler)
Parameter Description
uniqueId Pass the action's unique id generated on HyperTrack Server
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTAction? and HTError? as argument.
getPublishableKey

Call this method to get the PublishableKey configured in the SDK currently.

class func getPublishableKey() -> String?
Return Description
String Returns a string containing the PublishableKey if configured, nil otherwise.
getUserId

Call this method to get currently configured UserID.

class func getUserId() -> String?
Return Description
String Returns string containing the UserID if it is configured, nil otherwise.
locationAuthorizationStatus

Returns the app’s authorization status for using location services.

class func locationAuthorizationStatus() -> CLAuthorizationStatus
Return Description
CLAuthorizationStatus A value indicating whether the app is authorized to use location services.
motionAuthorizationStatus

Returns the app's authorization status for using motion sensors.

class func motionAuthorizationStatus(completionHandler: @escaping (_ isAuthorized: Bool) -> Void)
Parameter Description
completionHandler A block object which has no return value and takes a Bool value as argument which indicates whether motion activity is authorized or not.
isActivityAvailable

Returns a Boolean indicating whether motion data is available on the current device.

class func isActivityAvailable() -> Bool
Return Description
Bool Returns a Boolean indicating whether motion data is available on the current device.
requestMotionAuthorization

Call this method to request the motion permission.

class func requestMotionAuthorization()
registerForNotifications

Register to receive remote notifications via Apple Push Notification service.

class func registerForNotifications()
didRegisterForRemoteNotificationsWithDeviceToken

Provide the deviceToken to HyperTrack upon successful registration with APNs.

class func didRegisterForRemoteNotificationsWithDeviceToken(deviceToken: Data)
Parameter Description
deviceToken A token that identifies the device to APNs.
didFailToRegisterForRemoteNotificationsWithError

Inform HyperTrack that the device registration with APNs has failed.

class func didFailToRegisterForRemoteNotificationsWithError(error: Error)
Parameter Description
error An NSError object that encapsulates information why registration did not succeed.
isHyperTrackNotification

Returns a Boolean that indicates whether a push notification received on the device was sent by HyperTrack.

class func isHyperTrackNotification(userInfo: [AnyHashable: Any]) -> Bool
Parameter Description
userInfo A dictionary that contains information related to the remote notification.
Return Description
Bool A Boolean indicating whether the received push notification was sent by HyperTrack.
didReceiveRemoteNotification

Provide the userInfo dictionary received as part of push notification to HyperTrack for processing.

class func didReceiveRemoteNotification(userInfo: [AnyHashable: Any])
Parameter Description
userInfo A dictionary that contains information related to the remote notification.
getPlaceline

Fetches the placeline of the user for a given date.

class func getPlaceline(date: Date? = nil, userId: String? = nil, completionHandler: @escaping (_ placeline: HTPlaceline?, _ error: HTError?) -> Void)
Parameter Description
date An optional date object for which a user's placeline need to be fetched. If nil value is passed current date's placeline will be fetched.
userId An optional String value indicating a user's id. If nil value is passed placeline will be fetched for user currently configured with SDK.
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of HTPlaceline? and HTError? as argument.
setGeofenceAtPlace

Call this method to start monitoring for an entry in a given place.

class func setGeofenceAtPlace(place: HTPlace, radius: CLLocationDistance, identifier: String)
Parameter Description
place A place object around which a geofence need to be created.
radius The distance (measured in meters) from the coordinates point of the above mentioned place object to the edge of a circular geofence boundary.
identifier A unique identifier to associate with a geofence.
getCurrentActivity

Returns the last activity performed by the user.

class func getCurrentActivity() -> HTActivity?
Return Description
HTActivity The last known activity of the user. Returns nil if no activity was recorded earlier.
getPendingActions

Fetches a list of incomplete actions for the user.

class func getPendingActions(completionHandler: @escaping (_ action: [HTAction]?, _ error: HTError?) -> Void)
Parameter Description
completionHandler A block object to be executed when response is received from the server. This block has no return value and takes a tuple of array of HTAction and HTError? as argument.

results matching ""

    No results matching ""