Basic integration

With the Consumer SDK, you can show the ETA and status messages for a Task, and track progress in real-time on a map. This guide covers these objectives, by using the HTConsumerClient and HTMapView classes.

Initialise consumer client

To track a task, you need to call the trackTaskWithTaskID:completion method of HTConsumerClient.

This will require you to pass a taskID, which is the id of the task to be tracked. In addition, it needs a HTTaskBlock callback handler object, which returns an NSError object if there was an error while trying to track the task or returns an HTTask object if success

[info] Calling methods

For calling the methods in HTConsumer library, please use singleton [HTConsumerClient sharedClient].

- (IBAction)trackOrderButtonTapped:(id)sender {

  [[HTConsumerClient sharedClient] trackTaskWithTaskID:@"TASK_ID" completion:^(HTTask *task, NSError *error) {

    if (error) {
      // Handle error and try again.
    } else {
      // Tracking task was successful
    }
  }];
}

Track location on a Map

Consumer SDK provides the HTMapView class to enable real time tracking on a map. Once the consumer client model has been setup, you can initialise the map view with the following code. The map view will use the client model to get the task information.

The HTMapViewDelegate objects receives events like mapView:didTapCallButtonForTaskWithTaskID:, mapViewDidSucceed: etc.

We have delegate methods as callbacks to check if the task tracking began successfully or not. They are mapViewDidSucceed: and mapView:didFailWithError:. You can use these delegate methods to handle errors if there's an error in tracking. There is also a delegate method mapViewDidTapCallButton: which listens for taps on the order lookup button.

// HTMapView Methods
- (void)showMapView {
    HTMapView * mapView = [[HTMapView alloc] initWithFrame:self.view.frame];

    mapView.dataSource = self;
    mapView.delegate = self;

    [self.view addSubview:mapView];
}

- (void)mapView:(HTMapView *)mapView didTapCallButtonForTaskWithTaskID:(NSString *)taskID {

}

- (NSArray <NSString *> *)taskIDsToTrackForMapView:(HTMapView *)mapView {
    return @[@"Your task id"];
}

Was this helpful? Yes, thanks! Not really

results matching ""

    No results matching ""