Task

Teliver sdk provides you the way to manage your drivers with features that holds a strong grip on your business by Task management. The task type can be of three types Pickup, Drop and Pickup/Drop.

  • A Pickup task can be used to assign your driver to pickup a parcel/item from the provided location.
  • A Drop task can be used to assign your driver to drop a parcel/item to the provided location.
  • A Pickup/Drop task can be used to make your driver both pickup and drop a parcel/item from the provided locations.
Availability

You can set your drivers availability using the below snippet to filter out unavailable drivers while assigning.

Teliver.updateDriverAvailability(boolean value);
  • Utilize the boolean value as truethat set the status of the driver as available.
  • Utilize the boolean value as falsethat set the status of the driver as unavailable.
Driver Properties

In managing a huge delivery system you can categorize your driver’s list by assigning them a set of properties. The properties can be based on location he operates, Domain he operates, his work timings and so on based on your need.

Teliver.setDriverProperty(key, value);

For instance you can set a zone property to your driver by zones,

Teliver.setDriverProperty("zipcode", "600020");

Here you are categorizing the driver by his zip code i.e. 600020. you can use this property to list your driver via api according to the set property.

Task Notification

Your driver will be notified via push notification when a task has been assigned. To know about implementing push notifications in Teliver, please go through notifications.

public class FirebaseMessaging extends FirebaseMessagingService {

   @Override
   public void onMessageReceived(RemoteMessage remoteMessage) {
       super.onMessageReceived(remoteMessage);
       try {
           if (Teliver.isTeliverPush(remoteMessage)) {
               Map<String, String> pushData = remoteMessage.getData();
               NotificationData data = new  GsonBuilder().create().fromJson(pushData.get("description"),  NotificationData.class);
               if (data.getCommand().equals(TConstants.TELIVER_ASSIGN_TASK)) {
                   Task task = new GsonBuilder().create().fromJson(data.getPayload(), Task.class);

               Intentnt notificationIntent = new Intent(this,ActivityAssignedTask.class);
                   notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

                   PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
                           notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                   NotificationManager notificationManager = (NotificationManager)
                           this.getSystemService(Context.NOTIFICATION_SERVICE);
                   NotificationCompat.Builder notBuilder = new NotificationCompat.Builder(this);
                   notBuilder.setContentIntent(pendingIntent);
                   notBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
                   notBuilder.setSmallIcon(R.drawable.ic_notification_icon);
                   notBuilder.setContentTitle("Task Reminder");
                   notBuilder.setContentText(getNotifyContent(task.getType()));
                   notBuilder.setAutoCancel(true);
                   notBuilder.setOnlyAlertOnce(true);
                   Notification notification = notBuilder.build();
                   notification.defaults |= Notification.DEFAULT_SOUND;
                   notification.flags = Notification.FLAG_AUTO_CANCEL;

                   notificationManager.notify(7, notification);
               }

           }
       } catch (Exception e) {
           e.printStackTrace();
       }

   }

 }
  • Utilize Teliver.isTeliverPush to approve the push is from the teliver sdk.

  • The command message should contain the message as “teliver_assign_task”.

  • The payload will contain the data about the task and so on.

  • You can build a notification here to the driver indicating new task arrival.

The Taskobject contains everything that you would need for the task like task id, order id, type, pickup/drop location, contact details, time, notes etc.

Get Task

You can get your particular task contents by following a basic code.

Teliver.getMyTaskWithTaskId(taskId , new TaskListener() {
   @Override
   public void onSuccess(Task task) {

   }

   @Override
   public void onFailure(String reason) {

   }
});

To get list of all the task associated with driver based on the status can be listed by following method.

The underneath code piece will give you the assigned tasks.

Teliver.getMyTaskList("assigned", pageNo,Limit, new TaskListListener() {
   @Override
   public void onSuccess(List<Task> tasks, int total) {

   }

   @Override
   public void onFailure(String reason) {

   }
});

To get tasks with multiple status, provide the status in comma separated string as like below.

Teliver.getMyTaskList("accepted,in_progress" ,pageNo,limit, new TaskListListener() {
   @Override
   public void onSuccess(List<Task> tasks, int total) {

   }

   @Override
   public void onFailure(String reason) {

   }
});
Accept/Reject assigned tasks

When a task has been assigned to a driver, the driver can update the task by accepting it or by rejecting it. You can use the following two methods to accept or reject.

Teliver.acceptTask(taskId, new EventListener() {
   @Override
   public void onSuccess(String response) {

   }

   @Override
   public void onFailure(String reason) {

   }

You can likewise reject the task incase of any inconvenience by the beneath code.

Teliver.rejectTask(taskId, new EventListener() {
   @Override
   public void onSuccess(String response) {

   }

   @Override
   public void onFailure(String reason) {

   }
});
Start task

You can start the task by using the following code which inturn will update the status of the task to startedas well as create a trip with task id which is generated while creating the task. The task id can be used as tracking id to track the driver.

Teliver.startTask(taskId, new EventListener() {
   @Override
   public void onSuccess(String response) {

   }

   @Override
   public void onFailure(String reason) {

   }
});
Complete task

You can set the task as complete by the accompanying straightforward code.

Teliver.completeTask(taskId, new EventListener() {
   @Override
   public void onSuccess(String response) {


   }

   @Override
   public void onFailure(String reason) {

   }
});
Update status

You can update the status of individual pickup and drop status before completing by following methods.

This code works to updates a pickup task and sets isComplete = true, in the pickup object.

Teliver.completePickupTask("taskId", new EventListener() {
   @Override
   public void onSuccess(String response) {

   }

   @Override
   public void onFailure(String reason) {

   }
});

This updates a drop task and sets isComplete = true in drop object.

Teliver.completeDropTask("taskId", new EventListener() {
   @Override
   public void onSuccess(String response) {

   }

   @Override
   public void onFailure(String reason) {

   }
});

results matching ""

    No results matching ""