deactivate static method
Deactivates a product previously activated with a license key.
Initiates a deactivation request for licenseKey and productId. The
asynchronous onComplete callback reports the final result and a hint
string explaining errors or next steps.
Do not confuse deactivation with deletion of an activation record on the device. Deactivation notifies the activation service that the license is no longer in use on this device, allowing it to be reactivated elsewhere if the license terms permit. Deletion simply removes the activation record locally without notifying the activation service.
After deactivation, the ActivationInfo.status of the corresponding activation will be updated to reflect the deactivated state.
Parameters
applicationId: The application identifier owning the activation.licenseKey: The license key (UUID v4) to deactivate.productId: The product identifier to deactivate. Defaults to ProductID.core.onComplete: Callback invoked on completion. The callback receives:- GemError.success: Deactivation succeeded.
- GemError.required: No internet; Try again later or complete the deactivation offline. Follow the steps from the manual for manual offline deactivation.
- GemError.invalidInput: Invalid input; check the hint for details.
- GemError.io: IO error when accessing license file from disk.
- GemError.noMemory: Allocation failed on the platform.
- GemError.networkFailed: Network request failed to start.
Returns
- TaskHandler: A task handle when the deactivation request started successfully, otherwise
null.
Also see:
- activate - Perform activation.
- getActivationsForProduct - Retrieve activation information.
- deleteActivation - Deletes an activation record from local storage.
Implementation
static TaskHandler? deactivate({
required final String applicationId,
required final String licenseKey,
final String productId = ProductID.core,
required final void Function(GemError error, String hint) onComplete,
}) {
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
progListener.registerOnCompleteWithData((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
onComplete(GemErrorExtension.fromCode(err), hint);
});
final OperationResult resultString = staticMethod(
'ActivationService',
'deactivate',
args: <String, dynamic>{
'applicationId': applicationId,
'licenseKey': licenseKey,
'productId': productId,
'listener': progListener.id,
},
);
final GemError errorCode = GemErrorExtension.fromCode(
resultString['result'],
);
if (errorCode != GemError.success) {
return null;
}
return TaskHandlerImpl(progListener.id);
}