LicenseManager initialization
The LicenseManager is entry point to the LicenseSpring SDK.
As soon as you initialize the SDK, you will be able to contact the LicenseSpring server through it
to check if there is an existing license for the current computer / product combination.
If there is a current license available, it will be immediately accessible as a currentLicense
property.
There are three mandatory parameters to initialize the SDK:
- apiKey: your company API key
- sharedKey: company-specific encryption key, used when signing requests
- productCode: a two-three-letter string identifying the product (particular application)
All of these values are available to you in the LicenseSpring web platform under “SDK integration” section.
SDK configuration is made through Configuration
object. It is created with mandatory parameters and can be
extended after with additional ones:
import LicenseSpring
// Create the configuration
let configuration = Configuration(
apiKey: LICENSESPRINGAPIKEY,
sharedKey: LICENSESPRINGSHAREDKEY,
productCode: LICENSESPRINGPRODUCTSHORTCODE
)
// [Optional] Customize configuration
configuration.appName = "Custom app"
configuration.appVersion = "1.0.0"
// Create LicenseManager
let licenseManager = try LicenseManager(configuration: configuration)
LicenseManager functional
After setting up the LicenseManager (previous section), there is a number of methods and objects available to the app developer.
currentLicense
Property that returns the currently active License
object
if let license = licenseManager.currentLicense {
print(license.licenseKey ?? "not key-based license")
} else {
print("No current license")
}
requestTrialKey
You can generate a trial key directly from the app using the SDK, with an optional email parameter, which will automatically associate this license key with the provided email. You can later use this data from the LicenseSpring platform to send out email campaigns targeting trial users for example.
Note: After you generate a trial key, you still need to activate it using appropriate method!
// Key-based product
let trialKey = try licenseManager.requestTrialKey(with: nil)
// User-based product
let trialKey = try licenseManager.requestTrialKey(with: "example@gmail.com")
activateLicense
Attempts to activate the product using provided license key or user credentials.
let license = try licenseManager.activateLicense(licenseKey: proposedLicense)
// OR
let license = try licenseManager.activateLicense(user: "example@gmail.com", password: "p@ssw0rd")
requestAvailableVersions
Request all available app versions for the license user.
let versions = try licenseManager.requestAvailableVersions(licenseKey: proposedLicense)
// OR
let versions = try licenseManager.requestAvailableVersions(user: "example@gmail.com")
requestInstallationFile
Returns the (latest) valid installation file, if installation files are defined in the LicenseSpring platform. Requests installation information for the macOS platform.
let latestFile = try licenseManager.requestInstallationFile(licenseKey: proposedLicense)
// OR
let latestFile = try licenseManager.requestInstallationFile(user: "example@gmail.com")
// OR (with specific version)
let specificFile = try licenseManager.requestInstallationFile(user: "example@gmail.com", version: "1.0.1")
requestProductDetails
Request information about the product from LicenseSpring platform.
let productDetails = try licenseManager.requestProductDetails()
checkConnection
Helper method to check connection to the LicenseSpring platform.
let hasConnection = licenseManager.checkConnection()