Setup and manage devices

Identifying your app user devices

Tracking business assets on the move requires identification of your app users and their physical devices. To achieve this goal, HyperTrack uses a unique, randomly generated device id in order to track the physical device your app is used on.

Location data generated by your app user is sent to HyperTrack platform and stored together with the unique device id which identifies your app user.

With this unique device id, HyperTrack gives you the power of its APIs to manage tracking of your business assets.

Once you integrated HyperTrack SDK into your app, from your app backend, you can use HyperTrack APIs with device id to start and stop tracking of your app user's device from your server, create and complete trips for your app users, create geofences and track their entries and exits for each physical device in realtime.

What is a HyperTrack device id?

HyperTrack SDKs use random generated universally unique ids (UUIDs) that are stored in the device for future use once your SDK instance is initialized.

This device id is different for each physical device and is typically not persistent across uninstalls or re-installs of your app to ensure user's privacy.

Getting and storing your HyperTrack device id

Once you integrate HyperTrack SDK in your app, you may get device id from your SDK instance.

In your app integration code, retrieve an SDK instance, when you wish to use SDK, by passing your publishable key from the setup page. Once you get an SDK instance, you may get device id as shown in code samples below for iOS and Android HyperTrack SDK integration examples.

val publishableKey = "your-publishable-key-here"
val sdkInstance = HyperTrack.getInstance(this, publishableKey)
// Your HyperTrack device id
val deviceId = sdkInstance.deviceID

Once you obtained a device id as shown in the examples above, you should store this device identifer together with your app user identity in your own data store for future usage with HyperTrack API. You will need to map your own app user identity to HyperTrack device id to manage tracking of your app user's devices.

When you dispatch someone for a gig job, tracking a mobile worker via your app, create an order for an on-demand delivery, or tracking a driver via a logistics app, you need to use HyperTrack device id to track location of physical devices used by your app users.

Device name and metadata

While HyperTrack uses a device id to track your app with HyperTrack SDK integration, convenience methods are provided to help set device name and metadata as an option to help display, sort, manage, and organize large fleets of devices in your account.

While HyperTrack device id is a unique identifier for all of your app user's devices in your HyperTrack account, HyperTrack APIs do not enforce uniqueness constraints on name and metadata.

See an example of device name and metadata that are set for three devices with device_id such as 7BEEABA4-4890-4AFA-916A-AA80FE659C5A and D5FCE235-4650-476F-9871-59AC7F9BE48B.

{ "device_id": "D5FCE235-4650-476F-9871-59AC7F9BE48B",
"name": "Kishan E",
"metadata": {
"vehicle_type": "scooter",
"group_id": 1
}
},
{ "device_id": "7BEEABA4-4890-4AFA-916A-AA80FE659C5A",
"name": "Alex K",
"metadata": {
"vehicle_type": "bike",
"group_id": 2
}
}

Devices name is used to conveniently show your app user's device, filter, and search for it in HypeTrack dashboard.

Your device metadata can be any valid JSON string and be used for filtering purposes to help identify a group of devices that share common or distinct properties of your choosing. For example, please review how device metadata can be used to create hierarchical embedded views.

Setting device name and metadata

Once you set a name for your physical device, it will be used to display your app user's device in your account HyperTrack dashboard.

If you do not set a name for your app user's device, alternatively, its device id will be shown. As mentioned earlier, there is no requirement for device names to be unique. For example, if your app has a name for an app user in your user management system, you may as well use it to set the device name as well for the HyperTrack device id to create a consistent user experience for your customers.

As a developer, you have an option of being able to set and change device name and metadata via HyperTrack SDK in your mobile app as well as via HyperTrack Device API from your app server backend.

To get a hands-on experience of setting and changing device name and metadata without writing a single line of code, please visit HyperTrack Playground. Once you select your app user's device in the list inside Playground, you will be presented with device name and metadata entry forms. As you change them, please observe how your changes get reflected in HyperTrack Dashboard.

Setting device name and metadata in your mobile app

When you develop your app with HyperTrack location tracking, you may already have a requirement or preference to set your app user's device name and/or metadata once the app user started and logged into your app.

In this case, inside your mobile app, you may be able to set device name and metadata as shown below.

// Set device name as in the example above
sdkInstance.setDeviceName("Kishan E")
// create new metadata map
Map<String,Object> myMetadata = new HashMap<>();
// add metadata as in the example above
myMetadata.put("vehicle_type", "scooter");
myMetadata.put("group_id", 1);
sdkInstance.setDeviceMetadata(myMetadata);

Setting device name and metadata from your server backend

In addition to SDK methods above, HyperTrack provides you Devices API where you may be able to set device name and/or metadata.

You may need this when you have a business workflow that requires updating your app user's device name, or a change for your app user which may have to be reflected in your metadata.

For example, you want to restrict viewing of an operations team to their manager which, in turn, can be done by specifying an attribute to which your app users belong to, such as group_id from the example above.

Once you have used Devices API to set device name or device metadata, you can no longer use SDK methods to change them.
// Use Node.js helper library to set device metadata
const accountId = "your_account_id"
const secretKey = "your_secret_key"
// Instantiate Node.js helper library instance
const hypertrack = require('hypertrack')(accountId, secretKey)
const deviceName = "Kishan E"
// Set name for the device
hypertrack.devices.changeName(deviceId, deviceName).then(() => {
// Name changed
}).catch(error => {
// Error handling
})
const metadata = {"vehicle_type": "scooter", group_id":1}
hypertrack.devices.patchMetadata(deviceId, metadata).then(() => {
// Metadata set
}).catch(error => {
// Error handling
})

Retrieving your app user device data and status

In your business workflow, you may need to be able to retrieve device data and tracking status for a device id registered under your HyperTrack account. Conveniently, HyperTrack Devices API provides you an option to do so.

With this Devices API GET call,

GET /devices/{device_id}

with an example response as shown:

{
"device_id": "00112233-4455-6677-8899-AABBCCDDEEFF",
"location": {
"speed": 4.20,
"accuracy": 14.09,
"bearing": 193.12,
"geometry": {
"type": "Point",
"coordinates": [
35.1016383,
47.8391314,
65.40
]
},
"recorded_at": "2019-07-18T18:01:59.064000Z",
},
"device_status": {
"data": {
"recorded_at": "2019-07-30T01:38:45.610000Z",
"activity": "stop"
},
"value": "active"
},
"views": {
"share_url":"https://trck.at/abcdef",
"embed_url":"https://embed.hypertrack.com/devices/00112233-4455-6677-8899-AABBCCDDEEFF?publishable_key=abc"
},
"battery": "normal",
"device_info": {
"timezone": "America/Los_Angeles",
"os_name": "iOS",
"device_brand": "Apple",
"sdk_version": "3.3.2",
"device_model": "iPhone X",
"network_operator": "T-Mobile",
"name": "Alex’s Phone",
"os_version": "12.4"
},
"registered_at": "2019-07-10T01:38:45.610000Z",
"metadata": { ... }
}

This response delivers your app user's device most recently known recorded location, its current device status, provides you a publicly shareable share_url for the device location as well as embeddable embed_url that you can use to create a single device view dashboard. Lastly, you can see device's name, metadata, as well as device_info field as shown above along with it's registration UTC timestamp in registered_at.

Additionally, HyperTrack Devices API provides you ability to query all registered devices in your account.

Viewing your app user device info in dashboard

This device_info for your app user's device is also available as a device card once you click on a device on the map in HyperTrack Dashboard as shown below.

Device Card



Selecting a device gives you the option to look at device info, including:

  • Brand: Name of the device producer
  • Model: Product name of the device
  • Network: Network provider in use
  • Timezone: Timezone set on the device
  • OS: Operating system and version on the device
  • App package name: Package name of the application that HyperTrack is integrated into
  • App version: Version of the app that is using the HyperTrack SDK
  • SDK version: Version of the HyperTrack SDK used in the app
  • Created at: Date and time when the device was added to HyperTrack systems
  • Play services: Version of Play Services running on the Android device. Not visible for iOS devices.

Understanding app update, uninstall, and reinstall scenarios

As your user performs an app update with your next release, HyperTrack device_id does not change. HyperTrack keeps track of your app user's device id in this case, as well as updating relevant fields inside device info returned to you by Devices API GET call.

Once your app user uninstalls your app, mobile OS requires that all data associated with your app are removed to protect user's privacy. If your app user's device was actively tracking at the time, HyperTrack will detect and mark it's tracking status as disconnected.

In case if your app user uninstalls and subsequently installs your app again, the new installation will result in creation of a new device id even though it's the same physical device that belongs to your app user. Depending on your app workflow, if you expect a single physical device for each user, you may take advantage of either device name and/or metadata to determine a new installation and update your data store accordingly to keep track of new device id in your system.

Managing your app user turnover

Sometimes you may have a case where an app user leaves your organization or you want to permanently stop this app user being tracked.

In order to remove the physical device associated with this app user, you may use delete API method to delete this device and stop tracking it permanently. At the same time, after deleting this device id, HyperTrack will retain and provide tracking history of the device in dashboard views as well via API.

The device will stop tracking further and you will be unable to start tracking the same device ID again.

Once a new monthly billing cycle begins, you will not be charged for this device moving forward. Please see code snippets explaining device deletion below.

// Instantiate Node.js helper library instance
const hypertrack = require('hypertrack')(accountId, secretKey);
hypertrack.devices.delete(deviceId).then(() => {
// Device deleted
}).catch(error => {
// Error handling
})
note

To get a deleted device back into your account and start tracking, please check Devices Undelete API documentation.

Questions?

If your have urgent needs to help you with device management and location tracking, questions or comments on any of the topics above, please do not hesitate to contact us.

Is this page useful?