Timed Trials
Timed trials let customers evaluate your app for a limited period before buying. A trial activation is keyless, so the user starts one without entering a license key. Cryptlex trials are verified and node-locked, so a trial does not reset if the user reinstalls your app or reformats the machine. Each trial activation appears in the admin portal under Trials -> Trial Activations.
How a trial works
- Start the trial on first run with
ActivateTrial(). Call it once, ideally on a button click, not on every start, since each call re-validates against the Cryptlex servers. - Verify on every start with
IsTrialGenuine(), after yourIsLicenseGenuine()check, and read the time left withGetTrialExpiryDate(). This works offline. - If verification returns any other status, the trial has either not been activated on this machine yet or could not be validated.
LA_FAILspecifically means the trial has not been activated on this machine, so it is the signal to show your "Start Trial" action. Handle the returned status before deciding to callActivateTrial(). - When the trial expires, the functions return
LA_TRIAL_EXPIRED; prompt the user to buy a license.
Trial fingerprint matching
When a trial is activated, the server matches the machine's fingerprint exactly, regardless of the configured fingerprint matching strategy. Calling ActivateTrial() again after a change in the machine's hardware configuration can therefore create a new trial activation with a fresh trial ID. SyncTrialActivation(), on the other hand, honors the fingerprint matching strategy for existing trials, so a minor hardware change does not prevent an already activated trial from syncing.
Resetting a trial during development
Trials cannot be reset by your customers, but while testing your integration you will want to start fresh trials on your own machine. To reset a trial, delete its trial activation on the Trials -> Trial Activations page in the admin portal, then call the Reset() function in your app.
Floating trials
Floating trials do not exist; trials are always node-locked. To let a customer evaluate floating licensing, create a floating license that expires after a short period, such as 30 days.
Enforcing periodic server contact
Trials validate locally and work offline. To require server contact during an evaluation, call SyncTrialActivation() from your app at the interval you want. It refreshes the local trial data from the server, so server-side changes such as an updated expiry date or a deleted trial activation take effect on the machine.
Extending a trial
You can extend a trial to give a customer more time to evaluate your product:
- Ask the customer for their trial ID. Your app gets it with
GetTrialId(). - In the admin portal, open
Trials -> Trial Activations, search for the trial ID, and from the actions menu chooseUpdate Expiration Date, pick the new date, and clickUpdate. - In your app, call
SyncTrialActivation()to pull the new expiry date to the client without reactivation. It also refreshes trial activation metadata if you have set any.
Sample code
For the full flow and per-language samples, see Using LexActivator.
// On every start, after the IsLicenseGenuine() check
status = IsTrialGenuine();
if (LA_OK == status) {
// trial is active
unsigned int trialExpiryDate = 0;
GetTrialExpiryDate(&trialExpiryDate);
} else if (LA_TRIAL_EXPIRED == status) {
// trial has expired, prompt the user to buy a license
} else {
// trial has not started, start it (for example, on a button click)
status = ActivateTrial();
}