Build Order Tracking in iOS

In this guide, we will setup the HyperTrack SDK in your iOS app, and call trackAction method to live track an order within your app.

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.

[warning] Xcode project

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

use_frameworks!

target 'AppName' do
   pod 'HyperTrack'
end

[info] Minimum Deployment target

HyperTrack SDK support iOS 8.0 and above as deployment targets.

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.

[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”, “CocoaMQTT” and “HyperTrack” libraries.

import HyperTrack

HyperTrack.initialize("YOUR_PUBLISHABLE_KEY")

Step 3: Setup View Controller

  • Firstly, initialize HyperTrack Map instance and embed this in your view.

  • Secondly, if you want to get callback on various events which happen on HyperTrack map, add HTViewInteractionDelegate extension to your view controller and set it using hyperTrackMap.setHTViewInteractionDelegate API.

    Refer here for more details on view interaction APIs.

  • Optionally, if you want to enable customizations for UI elements, add HTViewCustomizationDelegate extension to your view controller. Once this is done you can implement customization methods to conform to your app's theme and set it using hyperTrackMap.setHTViewCustomizationDelegate API.

    Refer here for more details on customization APIs.

[info] Handle Back Button click

In order to handle back button click, didTapBackButton API needs to be implemented as depicted in the code snippet.

class MapViewController: UIViewController, HTViewInteractionDelegate, 
    HTViewCustomizationDelegate {
  override func viewDidLoad() {
    super.viewDidLoad()

    ...

    // Instantiate HyperTrack map view and embed this in your view
    let hyperTrackMap = HyperTrack.map()

    // Configure view interaction delegate in HyperTrack map
    hyperTrackMap.setHTViewInteractionDelegate(interactionDelegate: self)

    // Configure view customization delegate in HyperTrack map
    hyperTrackMap.setHTViewCustomizationDelegate(customizationDelegate: self)

    ...
  }

  // Handle back button tap
  func didTapBackButton(_ sender: Any) {
    self.dismiss(animated: true, completion: nil)
  }
}

Step 4: Embed HyperTrack view in your ViewController

Add a UIView where the HyperTrack Map view will be embedded.

[info] For Full screen HyperTrack map view

In case you want a full screen HyperTrack map view, embed your View controller's view as hyperTrackMap.embedIn(self.view).

class MapViewController: UIViewController, HTViewCustomizationDelegate, 
    HTViewInteractionDelegate {

  // Add a UIView in the storyboard layout where HyperTrack view 
  // will be embedded
  var hypertrackView: UIView?

  override func viewDidLoad() {
    super.viewDidLoad()

    ...

    // Embed HyperTrack map in your ViewController
    hyperTrackMap.embedIn(self.hyperTrackView)
  }
}

Step 4: Track Actions

Call the trackAction method with the Action Id that you want to track.

import HyperTrack

HyperTrack.trackActionFor(actionID: <ACTION_ID_HERE>)

[success] Live Tracking View integration completed

We have the tracking experience successfully integrated now and you are ready to deploy it in production.

Step 5: Sample Reference

Check out our open-sourced live tracking view (swift) repository for detailed reference.

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""