SDKs
...
Licensing Scenarios
License Type Options

Subscription

10min

In this guide, we'll delve into the realm of subscription licensing, accompanied by LicenseSpring's powerful SDKs.

Whether you're a seasoned developer or just beginning, this tutorial will equip you to seamlessly integrate subscription licenses into your software offerings.

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.

Interpreting and Retrieving Validity Period

Similar to time-limited licensing, you gain the ability to set the default validity period for generated license keys.

This validity period signifies the duration in days between the initial activation of the license key and its expiration.

With subscription licenses, however, there exist getters for the validity period including the grace period.

Just like with time-limited licenses, the SDKs offer the ability to retrieve these fields in local time and UTC:

C++
C#
Python


Interpreting and Retrieving Grace Period

Grace periods offer you the flexibility to determine a specific timeframe, measured in hours, subsequent to the expiry of the designated validity period.

During this defined interval, the license will retain its validity (isExpired() status will remain false), ensuring a seamless transition even after the official expiration.

To access the current license's grace period, developers can use the following:

C++
C#
Java
Swift
Python


Note: C++ and C# grace period retrieval returns the time remaining in hours, while the Java implementation returns days remaining.

It is also possible to check whether the grace period has started through:

C++
C#
Python


How to Verify if a License has Expired

By employing our system, you can easily determine whether a license has expired or remains valid.

This process empowers you with accurate information to manage software access effectively, ensuring a seamless user experience.

Utilizing the "isExpired" Method to Check License Expiry

The isExpired() method provides an efficient way to check whether a license has reached its expiration date.

Our SDKs offer the ability to check the expiration status through the use of the following License methods:

C++
C#
Java
Swift
Python


Note: Our Java SDK's isExpired() method is called on the LicenseData object.

Implementing Local Checks for License Expiry

A local license check involves assessing the validity and expiration status of a software license within the immediate operating environment.

By performing checks locally, the software verifies the license's authenticity and expiration status without relying on external connections.

If the local license is expired, the SDKs will throw the following exceptions:

C++
C#
Java
Python


See License Checks for more information about local license checks.

Understanding the "Days Remaining" Value

Developers can also access a field within the License object that holds the number of days remaining until the license expires.

This number of days can be retrieved using the following methods, in the current time zone and UTC, respectively:

C++
C#
Java
Python


Note: The Java SDK only offers the ability to retrieve the days remaining in the current time zone.



Updated 04 Oct 2024
Doc contributor
Doc contributor
Did this page help you?