SDKs
...
Tutorials
Best Practices

Device Variables Usage

10min

Device variables play a crucial role in LicenseSpring's SDKs by facilitating the exchange of data from devices to the vendor platform.

This mechanism allows developers and administrators to gather real-time device-specific information, empowering them to make informed decisions and tailor licensing strategies based on accurate insights.

The aim of this section is to provide you with a comprehensive understanding of effectively utilizing device variables.



Prerequisites

  1. Completed the Getting Started Tutorial, including:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Activated a license of any type.
    • Implemented routine local and online checks within the application.

Understanding Device Variable Usage

Some examples of scenarios where device variables are useful:

Hardware Specifications

Device variables can be utilized to capture and transmit hardware specifications, such as CPU type, RAM size, and storage capacity.

This information can be invaluable for tailoring licenses based on the user's hardware capabilities.

Tracking User Registration Data

User registration data includes names and user information, which can be sent and kept track of on the LicenseSpring platform using these variables.

This enables you to gather and manage essential user details directly within the licensing framework, streamlining administrative tasks and enhancing user experience.

User Preferences:

Store user preferences, settings, and configurations using device variables to create a more personalized and seamless user experience.

Adding Device Variables

Integrating device variables is simple with the LicenseSpring SDK, and on existing licenses can be done in three different ways:

  1. Adding a name-value pair
  2. Adding a DeviceVariable object
  3. Adding multiple DeviceVariable objects via vector/array.
C++
C#
Swift
Python


Note: To update a device variable, you can simply add the device variable with the same name, and it’s updated value.

Device variables can also be set on license activation:

C#
C++
Python


Accessing Device Variables

To locate the device variables through the vendor platform, first navigate to your license then to the "Devices" tab.

Device tab where device variables are found.
Device tab where device variables are found.


Next, click on the device variables button to open a list of the device's device variables.

Device Variables button
Device Variables button

C++
C#
Swift
Python


Note: The SDKs have the ability to retrieve device variables from either the local license or from the backend. The Boolean that is passed as the parameter into the getDeviceVariables function decides where they are retrieved from.

True gets the device variables from the backend, whereas False searches the local license.

By default, this false is set to false. If no parameters are passed to this method, it will retrieve from the local license.