-
Notifications
You must be signed in to change notification settings - Fork 0
LicenseClient
Used to activate, store, and load software licenses.
public class LicenseClientInitialize a LicenseClient with an array of public keys that are known to the application.
public init(knownPublicKeys: [SecKey])- knownPublicKeys: An array of public keys. The keys must be exportable.
Load and validate the stored license, if any.
public func loadLicense() throws -> License?LicenseLoadError if the license failed to be loaded or validated.
The license, if any.
Send a request to the activation server to activate a trial for this device.
public func activateTrial(usingEndpoint endpointURL: URL, runningCompletionHandlerOn completionQueue: DispatchQueue, completionHandler: @escaping (_ result: Result<License, ActivationError>) -> Void)The request will use the HTTP POST method. The request JSON looks like
{
"device_uuid": "9CAE2AA4-3268-4AF7-A75D-7B176251F0A7"
}
The activation server must respond with a 200 status code if it is sending a JSON payload; any other status code will be regarded as a rejection of the request.
The response JSON looks like
{
"signed_license": "<base64-encoded data>"
}
The value of signed_license is a LicenseInfo struct wrapped in a SignedBundle struct,
serialized using the Protocol Buffers library. See SignedBundle.proto and LicenseInfo.proto
for the Protocol Buffers schemas.
- endpointURL: The HTTP(S) URL of the trial activation endpoint. HTTPS is recommended over plaintext HTTP.
- completionQueue: The dispatch queue that the completion handler will run on.
- completionHandler: The closure that is called when the activation succeeds or fails.
- result: The license or an
ActivationError. Note that, depending on the server-side logic, the trial activation endpoint may return a purchased license if a purchase was previously activated on this device.
Send a request to the activation server to activate a purchase for this device.
public func activatePurchase(forLicenseKey licenseKey: String, usingEndpoint endpointURL: URL, runningCompletionHandlerOn completionQueue: DispatchQueue, completionHandler: @escaping (_ result: Result<PurchasedLicense, ActivationError>) -> Void)The request will use the HTTP POST method. The request JSON looks like
{
"device_uuid": "9CAE2AA4-3268-4AF7-A75D-7B176251F0A7",
"license_key": "<user’s license key>"
}
The activation server must respond with a 200 status code if it is sending a JSON payload; any other status code will be regarded as a rejection of the request.
The response JSON for a successful activation looks like
{
"signed_license": "<base64-encoded data>"
}
The value of signed_license is a LicenseInfo struct wrapped in a SignedBundle struct,
serialized using the Protocol Buffers library. See SignedBundle.proto and LicenseInfo.proto
for the Protocol Buffers schemas.
The response JSON for a failed activation looks like
{
"activation_error": "<error code>"
}
The value of activation_error can be one of the following:
-
license_key_not_found -
device_quota_exceeded
- licenseKey: The license key that corresponds to the user’s purchase.
- endpointURL: The HTTP(S) URL of the purchase activation endpoint. HTTPS is recommended over plaintext HTTP.
- completionQueue: The dispatch queue that the completion handler will run on.
- completionHandler: The closure that is called when the activation succeeds or fails.
- result: The license or an
ActivationError.
Generated at 2020-11-18T05:36:12+0000 using swift-doc 1.0.0-beta.5.