deactivate static method

TaskHandler? deactivate({
  1. required String applicationId,
  2. required String licenseKey,
  3. String productId = ProductID.core,
  4. required void onComplete(
    1. GemError error,
    2. String hint
    ),
})

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:

Returns

  • TaskHandler: A task handle when the deactivation request started successfully, otherwise null.

Also see:

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);
}