Activation reclaim (Mac)
You can manage existing and previous activations for a license through the SDK, letting you deactivate older activations if the license being used has run out of available activations.
Get Activations
Section titled “Get Activations”You can get a list of existing activations using the activationsForLicense method available on PADProduct.
This method optionally accepts a license code if the product isn’t activated. If the product is already activated, it uses the currently activated license code. You can still pass in a different license code, if needed.
For example:
[product activationsForLicense:@"D97...3F37" completion:^(NSArray * _Nullable activations, NSError * _Nullable error) { NSLog(@"+++++++++ACTIVATIONS+++++++++++"); NSLog(@"%@", activations); }];product.activations(forLicense: "D97...3F37") { activations, error in print(activations) }This will provide you with a list of activations for that license code and product:
{
activated = "2022-06-01 12:23:42 +0000"; "activation_id" = 4...5; uuid = "00:00:00:00";}You can choose to display the list of activations to your customer or, for example, choose the oldest activation from the list to deactivate.
Deactivating an Activation
Section titled “Deactivating an Activation”Once you have a list of activations, you can use the deactivateActivation method to deactivate one or all the activations.
This method accepts an activation_id from the previous response. If this activation is the current activation on the machine, deactivation still takes place with the usual callbacks and delegate methods.
For example:
[product deactivateActivation:activationId license:@"D9...F37" completion:^(BOOL deactivated, NSError * _Nullable error) { if (deactivated) { NSLog(@"License Deactivated"); } }];product.deactivateActivation(activationId, license: "D9...F37") { deactivated, error in if deactivated { print("License Deactivated") } }Deactivate Oldest Activation Example
Section titled “Deactivate Oldest Activation Example”In this example, we get a list of activations and instantly deactivate the oldest activation in the list to free up a new activation.
We supply the license code because we assume the customer can’t activate because there’s no available activations for the license.
[product activationsForLicense:@"D9...F37" completion:^(NSArray * _Nullable activations, NSError * _Nullable error) { NSString *firstActivationId = [[activations firstObject] valueForKey:@"activation_id"]; [product deactivateActivation:firstActivationId license:@"D9...F37" completion:^(BOOL deactivated, NSError * _Nullable error) { if (deactivated) { NSLog(@"License Deactivated - Try activating again"); } }]; }];product.activations(forLicense: "D9...F37") { activations, error in let activationsList = activations as? [[String:Any]]
if let oldestActivation = activationsList?.first { product.deactivateActivation(oldestActivation["activation_id"] as! String, license: "D9...F37") { deactivated, error in if deactivated { print("License Deactivated - Try activating again") } } } }