License
@objc(LSLicense)
final class License
extension License : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol
The License. Contains information about the license and set of methods to manupulate it.
-
License configuration. Do NOT modify directly.
Declaration
Swift
@objc let configuration: Configuration
-
License key. Exists for key-based license.
Declaration
Swift
@objc var licenseKey: String? { get }
-
License user. Exists for user-based license.
Declaration
Swift
@objc var user: User? { get }
-
Product code.
Declaration
Swift
@objc var productCode: String { get }
-
Type of license.
Declaration
Swift
@objc var licenseType: LicenseType { get }
-
Information about license customer, commonly it’s a person or organization associated with the license.
Declaration
Swift
@objc var customer: Customer { get }
-
Period when the license is valid.
Declaration
Swift
@objc var validityPeriod: Date? { get }
-
Maintenance period for the license.
Declaration
Swift
@objc var maintenancePeriod: Date? { get }
-
The first date when the license can be activated
Declaration
Swift
@objc var startDate: Date? { get }
-
The date of the last sync with the LicenseSpring platform.
Declaration
Swift
@objc var lastSyncDate: Date { get }
-
If license is trial.
Declaration
Swift
@objc var isTrial: Bool { get }
-
If license is active.
Declaration
Swift
@objc var isActive: Bool { get }
-
If license is enabled.
Declaration
Swift
@objc var isEnabled: Bool { get }
-
If license was activated offline.
Declaration
Swift
@objc var isOfflineActivated: Bool { get }
-
If license was activated via Air-Gap.
Declaration
Swift
@objc var isAirGapActivated: Bool { get }
-
PolicyID related to AirGap activation.
Declaration
Swift
@objc var policyID: Int { get }
-
Installation information related to the license.
Note
To get actual installation file information, callsynchronize
method first.Declaration
Swift
@objc var installationFile: InstallationFile? { get }
-
Hardware ID related to the license.
Declaration
Swift
@objc var hardwareID: String { get }
-
Current state of the license.
Declaration
Swift
@objc var state: LicenseState { get }
-
If license have been expired.
Declaration
Swift
@objc var isExpired: Bool { get }
-
Fast and simple way to check current local state of the license.
Note
Equivalent to isEnabled && isActive && !isExpired.Note
It’s just basic check, you cannot be 100% sure that license is valid without online license check. You still need to perform full license check for better safety.Declaration
Swift
@objc var isValid: Bool { get }
Return Value
If license is valid.
-
If license copy is unlicensed.
Declaration
Swift
@objc var isUnlicensedCopy: Bool { get }
-
If maintenance period have been expired for current license.
Declaration
Swift
@objc var isMaintenancePeriodExpired: Bool { get }
-
Grace period of the license.
Note
Meaningful only forsubscription
license.Declaration
Swift
@objc var gracePeriod: TimeInterval { get }
-
Check license for validity on the LicenseSpring platform.
Throws
Error if remote or local checks fail.Declaration
Swift
@objc func fullCheck() throws
-
Check license for validity offline.
Throws
Error if check fails.Declaration
Swift
@objc func localCheck() throws
Return Value
Boolean indicates if local check passed or not.
-
Retrieves fresh license information from the LicenseSpring platform.
Throws
Error if synchronization fails.Declaration
Swift
@objc func synchronize() throws
-
How many times license already been activated.
Declaration
Swift
@objc var timesActivated: Int { get }
-
How many times license can be activated.
Declaration
Swift
@objc var maxActivations: Int { get }
-
Deactivate the license.
Throws
Error if deactivation fails.Declaration
Swift
@objc func deactivate() throws
-
Updates license with offline update file.
Throws
Error if update fails.Declaration
Swift
@objc func updateOffline(with file: URL) throws
-
Creates offline deactivation file request.
Throws
Error if creation of deactivation request fails.Declaration
Swift
@objc func deactivateOffline(preferredRequestFile: URL? = nil) throws -> URL
Parameters
preferredRequestFile
Optional custom deactivation request file location. ‘~/Desktop/ls_deactivation.req’ by default.
Return Value
Location of offline deactivation file request.
-
Generate air gap Deactivation code.
Throws
LSError if code generation fails.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) func generateAirGapDeactivationCode(initializationCode: String) throws -> String
Parameters
initializationCode
Code received from the air gap activation portal.
Return Value
Air gap Dectivation code.
-
Verify Confirmation code and deactivate air gap license.
Throws
LSError in case confirmation code from the air gap activation portal is invalid.Declaration
Swift
@available(macOS, introduced: 10.15) @available(iOS, introduced: 13.0) func deactivateAirGap(confirmationCode: String) throws
Parameters
confirmationCode
Code received from the air gap activation portal.
-
Product features available for the license.
Declaration
Swift
@objc var features: [LicenseFeature] { get }
-
Updates feature consumption by some diff (positive or negative).
Throws
Error if update fails.Declaration
Swift
@objc func updateFeatureConsumption(code: String, difference: Int) throws
Parameters
code
Feature code.
difference
Difference of consumption number.
-
Sync Consumption Feature(s) with the LicenseSpring platform.
Note
Meaningful only for Consumption features.Throws
Error if sync fails.Declaration
Swift
@objc func syncFeatureConsumption(code: String?) throws
Parameters
code
Code of the license feature that need to be synchronized. If
nil
, sync all consumption features. -
If the license is floating type. Meaningful only for Floating license.
Declaration
Swift
@objc var isFloating: Bool { get }
-
Maximum number of simultaneous license users (devices or instances). Meaningful only for Floating license.
Declaration
Swift
@objc var maxFloatingUsers: Int { get }
-
Current number of floatings slots in use, including this user (instance). The value can be actualized with
synchronize
method call. Meaningful only for Floating license.Declaration
Swift
@objc var floatingInUseCount: Int { get }
-
Timeout of the floating license. Meaningful only for Floating license.
Declaration
Swift
@objc var floatingTimeout: TimeInterval { get }
-
Floating user (client) or instance id that was set during registration via
FloatingClient
. Meaningful only for Floating license.Declaration
Swift
@objc var floatingClientID: String? { get }
-
Floating license validity end date. Meaningful only for Floating license.
Declaration
Swift
@objc var floatingEndDate: Date? { get }
-
How many times license has been transferred between devices.
Declaration
Swift
@objc var transferCount: Int { get }
-
Register floating license using floatingClientId
In order to keep floating license alive you should check (register) it periodically. This is equivalent to
synchronize
method call.Meaningful only for Floating license.
Declaration
Swift
@objc func registerFloatingLicense() throws
-
Revoke floating license, typically should be called at the end of app execution.
This call will also release (return) borrowed license.
Declaration
Swift
@objc func releaseFloatingLicense() throws
-
If the license is borrowed. Meaningful only for Floating license.
Declaration
Swift
@objc var isBorrowed: Bool { get }
-
If the license can be borrowed. Meaningful only for Floating license.
Declaration
Swift
@objc var canBorrow: Bool { get }
-
The license max borrow time in seconds. Meaningful only for Floating license.
Declaration
Swift
@objc var maxBorrowTime: TimeInterval { get }
-
Borrow floating license for provided time interval. Meaningful only for floating licenses.
Throws
Error if request fails. May be of
LSError
type.Note
More at /api/v4/floating/borrow.
Declaration
Swift
@objc func borrow(for interval: TimeInterval) throws
-
Borrow floating license till provided end date. Meaningful only for floating licenses.
Throws
Error if request fails. May be of
LSError
type.Note
More at /api/v4/floating/borrow.
Declaration
Swift
@objc func borrow(until date: Date?) throws
-
Custom data fields available for the license.
Declaration
Swift
@objc var customFields: [CustomField] { get }
-
Metadata JSON.
Declaration
Swift
@objc var metadata: Data? { get }
-
Information about the product this license is belong to.
Declaration
Swift
@objc var productDetails: ProductDetails { get }
-
Array of variables bound to license concrete device ID.
Declaration
Swift
@objc var deviceVariables: [DeviceVariable] { get }
-
Sends device-specific variables to the LicenseSpring platform.
Throws
Error if request fails. May be of
LSError
type.Note
More at /api/v4/track_device_variables.
Declaration
Swift
@objc func sendDeviceVariables(_ variables: [String : String]) throws
Parameters
variables
Dictionary of name-value pairs.
Return Value
Array of variables linked to the current running device ID.
-
Requests device-specific variables from the LicenseSpring platform. If succeeds, property
deviceVariables
is also updated.Note
Please note this data will be linked to the current running device ID.Throws
Error if sending data fails.
Note
More at /api/v4/get_device_variables.
Declaration
Swift
@objc func requestDeviceVariables() throws -> [DeviceVariable]
-
Request all available versions for the current license.
Throws
Error if request fails. May be ofLSError
type.Declaration
Swift
@objc func requestAvailableVersions() throws -> [AvailableVersion]
Return Value
An array of versions available for the license.
-
Request installation information for the current license.
Throws
Error if request fails. May be ofLSError
type.Declaration
Swift
@objc func requestInstallationFile(version: String? = nil) throws -> InstallationFile
Parameters
version
Desired product (app) version, optional. If not provided, the last available version assumed.
Return Value
Installation information related to the license.
-
Change password for user based license.
Throws
Error if request fails. May be of
LSError
type.Note
More at /api/v4/change_password
Declaration
Swift
@objc func changePassword(password: String, newPassword: String) throws
Parameters
password
Current user password.
newPassword
New user password.
-
If unlimited number or consumptions is allowed.
Note
Meaningful only for Consumption license.Declaration
Swift
@objc var allowUnlimitedConsumptions: Bool { get }
-
If reset consumption is enabled. Refer to value in
consumptionPeriod
.Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var isResetConsumptionEnabled: Bool { get }
-
Value of reset consumption period. Makes sense only if
isResetConsumptionEnabled
istrue
.Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var consumptionPeriod: ConsumptionPeriod { get }
-
If it’s allowed to go over
maxConsumptionOverage
.Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var isConsumptionOverageAllowed: Bool { get }
-
Maximum extra consumption value or 0 for
unlimited
value. 0 if license type is not Consumption.Declaration
Swift
@objc var maxConsumptionOverage: Int { get }
-
Change local consumption counter for consumption license.
Note
Meaningful only for Consumption based license.Throws
Error if sending data fails.Declaration
Swift
@objc func updateConsumptions(difference: Int) throws
Parameters
difference
Consumption value to be added or removed (if passed as negative).
-
Current total consumption or 0 if license type is not Consumption.
Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var consumptions: Int { get }
-
Maximum consumption value or 0 if license type is not Consumption.
Note
Meaningful only for Consumption based license.Declaration
Swift
@objc var maxComsumptions: Int { get }
-
Number of local consumptions not synchornized with LicenseSpring platform. May be negative.
Note
Meaningful only for Consumption feature type.Declaration
Swift
@objc var localConsumptionsDelta: Int { get }
-
Sync Consumption license with the server.
Throws
Error if sync fails.Note
Meaningful only for Consumption based license.Declaration
Swift
@objc func syncConsumptions() throws