LicenseManager

@objc(LSLicenseManager)
final class LicenseManager
extension LicenseManager : CVarArg, CustomDebugStringConvertible, CustomStringConvertible, Equatable, Hashable, NSObjectProtocol

Entry point to the LicenseSpring SDK Use to obtain the license or common product information

  • Init LicenseManager with configuration

    Throws

    LSError if input configuration is wrong

    Declaration

    Swift

    @objc
    init(configuration: Configuration) throws
  • Undocumented

    Declaration

    Swift

    @objc
    let configuration: Configuration
  • Filesystem path to the license.

    Declaration

    Swift

    @objc
    var licenseFile: URL { get }
  • Activated License or nil if no license is active.

    Declaration

    Swift

    @objc
    var currentLicense: License? { get }
  • Activate the license using license key.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(licenseKey: String) throws -> License

    Parameters

    licenseKey

    License key for the product.

    Return Value

    Activated license.

  • Activate the license using user and password.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(user: String, password: String) throws -> License

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    Return Value

    Activated license.

  • Activate the license using license activation response file.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicenseOffline(_ activationResponseFile: URL) throws -> License

    Parameters

    activationResponseFile

    Activation response file location.

    Return Value

    Activated license.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(licenseKey: String, preferredLocation: URL? = nil) throws -> URL

    Parameters

    licenseKey

    License key to be activated offline.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    Return Value

    Location of offline activation file request.

  • Creates offline activation file request.

    Throws

    Error if create activation file fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func createOfflineActivationFile(user: String, password: String, preferredLocation: URL? = nil) throws -> URL

    Parameters

    user

    User ID, typically email in lowercase.

    password

    User’s password.

    preferredLocation

    Optional custom activation request file location. ‘~/Desktop/ls_activation.req’ by default.

    Return Value

    Location of offline activation file request.

  • Get Activation code for air gap activation.

    Throws

    Error if generation fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func generateAirGapActivationCode(initializationCode: String, licenseKey: String) throws -> String

    Parameters

    initializationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    Return Value

    Air gap Activation code. Empty string in case of error.

  • Verify Confirmation code for air gap activation.

    Throws

    Error if verification fails. May be of LSError type.

    Declaration

    Swift

    @available(macOS, introduced: 10.15)
    @available(iOS, introduced: 13.0)
    @objc
    func verifyAirGapConfirmationCode(confirmationCode: String, licenseKey: String, policyID: Int) throws

    Parameters

    confirmationCode

    Code received from the air gap activation portal.

    licenseKey

    License key of air gap license.

    policyID

    Policy id received from the air gap activation portal.

  • Activate air gap license using policy file.

    Throws

    Error if activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(airgapPolicyFile policyFile: URL, licenseKey: String, policyID: Int) throws -> License

    Parameters

    licenseKey

    License key.

    policyID

    Id of the license policy.

    Return Value

    License if activation succeeded.

  • Retrieve URL for Single Sign-On license activation.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestSSOURL() throws -> URL

    Return Value

    URL for Single Sign-On.

  • Activate the license.

    Throws

    Error if license activation fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func activateLicense(ssoToken: String) throws -> License

    Parameters

    ssoToken

    id_token received from user authorization with SSO.

    Return Value

    Activated license.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(with email: String?) throws -> String

    Return Value

    Trial license key or user email in case of user-based product.

  • Request trial license from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    Combination of same hardwareID and product will ALWAYS give you the same trial key! This prevents people getting new trial keys on same computer.

    Declaration

    Swift

    @objc
    func requestTrialKey(for customer: Customer?, licensePolicy: String? = nil) throws -> String

    Parameters

    licensePolicy

    License policy code. If nil, the default license policy for the product will be used.

    Return Value

    Trial license key or user email in case of user-based product.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(licenseKey: String) throws -> [AvailableVersion]

    Parameters

    licenseKey

    License key.

    Return Value

    An array of versions available for the license.

  • Request all available versions for the license user.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestAvailableVersions(user: String) throws -> [AvailableVersion]

    Parameters

    user

    License user name, usually email in lowercase.

    Return Value

    An array of versions available for the license.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(licenseKey: String, version: String? = nil) throws -> InstallationFile

    Parameters

    licenseKey

    License key.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    Return Value

    Installation information related to the license.

  • Request installation information for the license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestInstallationFile(user: String, version: String? = nil) throws -> InstallationFile

    Parameters

    user

    License user name, usually email in lowercase.

    version

    Desired product (app) version, optional. If not provided, the last available version assumed.

    Return Value

    Installation information related to the license.

  • Request information about the product from LicenseSpring platform.

    Throws

    Error if request fails. May be of LSError type.

    Note

    In offline mode data will be retrieved from license file if present.

    Declaration

    Swift

    @objc
    func requestProductDetails() throws -> ProductDetails

    Return Value

    Product details.

  • Request all the license users on every order by some customer.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func requestLicenseUsers(for customerEmail: String) throws -> [User]

    Return Value

    Array of the users related to the customer.

  • Change password for user based license.

    Throws

    Error if request fails. May be of LSError type.

    Declaration

    Swift

    @objc
    func changePassword(user: String, password: String, newPassword: String) throws

    Parameters

    user

    User email.

    password

    Current user password.

    newPassword

    New user password.

  • Helper method to check connection to the LicenseSpring platform.

    Declaration

    Swift

    @objc
    func checkConnection() -> Bool

    Return Value

    true if SDK is able to connect to the LicenseSpring platform and false otherwise.

  • Remove license file and internal SDK files if any of them exist.

    Note

    Typically should be called after license deactivation in the app uninstaller.

    Throws

    Error if clearing fails.

    Declaration

    Swift

    @objc
    func clearLocalStorage() throws
  • Version of LicenseSpring SDK

    Declaration

    Swift

    @objc
    static let sdkVersion: String
  • Version of LicenseSpring API

    Declaration

    Swift

    @objc
    static let apiVersion: Int
  • Extract SSO license token from URL.

    Throws

    Error if urlString has invalid format or scheme mismatched.

    Declaration

    Swift

    @objc
    static func extractSSOToken(from urlString: String, scheme: String) throws -> String

    Parameters

    scheme

    Expected URL scheme to ensure URL is valid. If scheme mismatched, the error is thrown.

    Return Value

    SSO token to activate the license.