User

The User object represents the user who is being tracked. The identifier of the user is used in the SDK to identify the tracking device.

The User object

Method Type Description
getId uuid String Unique identifier for the object
getName String Name of the user
getPhone String Phone number of user
getGroupId String The id of the fleet to which this user belongs
getLookupId String A unique id that was added to the user to identify
getAvailabilityStatus String The availability status of the user, possible values are USER_STATUS_ONLINE, USER_STATUS_OFFLINE and USER_STATUS_ACTIVE
getPendingActions List<Action> List of action ids that have been assigned to the user and are not complete
getLastLocation HyperTrackLocation Last Location of user as HyperTrackLocation object
getLastHeartbeatAt Date Date time for last communication with the user's device
getLastOnlineAt Date Date time when the last tracking session was started for the user
getCreatedAt Date Timestamp of when user was created
getModifiedAt Date Timestamp of when user detail was last modified
isConnected boolean Is user device connected with HyperTrackServer

Connectivity Statuses

Connected Status Description
TRUE When the user's device is connected to internet along with SDK is able to send data to server.
FALSE When the user's device doesn't connected to internet OR Connected to internet but SDK is crashed or not able to push data to server.

Availability statuses

Availability status Description
USER_STATUS_ONLINE When the user's session has been started with startTracking on the SDK
USER_STATUS_OFFLINE When the user's session has been ended by stopTracking on the SDK
USER_STATUS_ACTIVE When the user has been assigned one or more Action - once the actions are completed, the user goes back to online

GetOrCreate User

Call this method to get or create a User on HyperTrack API Server for the current device with given lookup_id. If user is already exist on HyperTrack server with given lookupId then you will get the already created User object otherwise create a new user.

[info] User already created?

You can set an existing user id, in case you have created an user id via the backend API using the HyperTrack.setUserId("YOUR_USER_ID") method in the SDK.

UserParams

Parameter Name Type Method Name Description
name String setName Name of the user
phone String setPhone Phone number of the user
photo String setPhoto Web URL of photo file or Base64 string of user image file
lookupId String setLookupId A unique string identifier used to identify user on HyperTrack API server
groupId uuid String setGroupId A uuid string for group created on HyperTrack API server
UserParams userParams = new UserParams().setName(name)
                .setPhone(phoneNumber)
                .setPhoto(encodedImage)
                .setLookupId(phoneNumber)
                .setGroupId(groupId);

// getOrCreateUser API with lookup_id param will create a new user only if none exists already for the given lookup_id.
HyperTrack.getOrCreateUser(userName, phone, photo, lookupId, new HyperTrackCallback() {
   @Override
   public void onSuccess(@NonNull SuccessResponse response) {
       if (response.getResponseObject() != null) {
            User user = (User) response.getResponseObject();
            String userId = user.getId();
            // Handle user_id, if needed
            ...
       }
   }

   @Override
   public void onError(@NonNull ErrorResponse error) {
       // Handle createUser error here
       Toast.makeText(this, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
   }
});

Update User

Call HyperTrack.updateUser() API to update the user details.

UserParams userParams = new UserParams().setName(name)
                .setPhone(phoneNumber)
                .setPhoto(encodedImage)
                .setLookupId(phoneNumber)
                .setGroupId(groupId);

HyperTrack.updateUser(userParams, new HyperTrackCallback() {
    @Override
    public void onSuccess(@NonNull SuccessResponse successResponse) {
        if (response.getResponseObject() != null) {
            User user = (User) response.getResponseObject();
            // Handle user_id, if needed
            String userId = user.getId();

            ...
        }
    }
    @Override
    public void onError (@NonNull ErrorResponse errorResponse){
        // Handle updateUser error here
        Toast.makeText(this, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
    }
    });
}

Get UserId

Call HyperTrack.getUserId() API to get UserId configured in the SDK casted as a String.

String userId = HyperTrack.getUserId();

Get Users for a LookupId

Returns a user object for a given lookup_id parameter.

HyperTrack.getUsersForLookupId(lookupId, new HyperTrackCallback() {
  @Override
  public void onSuccess(@NonNull SuccessResponse response) {
    // Handle getUsersForLookupId response here   
    if (response.getResponseObject() != null) {
      List<User> users = (List<User>) response.getResponseObject();
      ...
    }
  }

  @Override
  public void onError(@NonNull ErrorResponse errorResponse) {
    // Handle getUsersForLookupId error
  }
});

results matching ""

    No results matching ""