Trial Licensing
In this guide, we will explore the powerful capabilities of LicenseSpring's trial licensing feature, which enables software vendors to offer time-limited evaluation periods for their products.
- 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.
Distinguishing trial and non-trial licenses involves several key differences:
- Limited Validity: Trial licenses have a predefined expiration date, restricting the user's access to the software after this date. In contrast, non-trial licenses typically have no time restrictions, allowing perpetual usage.
- Identifiability: The LicenseSpring SDKs can recognize trial licenses as distinct entities. This enables developers to implement conditional logic based on the license type. For instance, specific features can be locked off for trial licenses, providing a tailored trial experience.
Inside Settings --> Preferences --> Allow multiple licenses on trial. This checkbox will allow you to create unlimited trial on same hardware_id.
By integrating a LicenseSpring SDK into your application's codebase, you gain the ability to effortlessly generate and activate trial licenses.
It is shown how to create and enable a key-based trial license below:
Note: When using a key-based trial license, we leave the first parameter as a nullptr. When issuing a user-based trial license, we input the user email.
Note: If we leave the second parameter, or pass it an empty string, it will use our default license policy to create our trial license. Otherwise, we can pass it a specific license policy code to use that policy's license settings.
It is also possible to pass a string of an email as the lone parameter, as shown below:
It is straightforward to check whether the current license in your software application is a trial license.
Each SDK has a method within the License object that allows developers to distinguish between trial and non-trial licenses, as shown below:
The following sample code illustrates obtaining and activating trial licenses for both key and user-based licenses.
For the sample code to operate for user-based license, simply replace the nullptr in Customer::ptr_t user = nullptr with a Customer object.
Also, licensePolicyCode can be set to the string of any license policy code associated with the license, otherwise if left as empty it will use the default license policy.
After activating a trial license, developers can control the state of the application through the isTrial() method accessible through the License object.
This functionality is shown below:
Exceptions that might occur when performing offline license activation:
- TrialNotAllowedException: Trial is not allowed by product license policy.