activate static method

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

Activates a product using the supplied license key.

Starts an activation flow for productId using licenseKey (a UUID v4). The operation is asynchronous and the onComplete callback reports final status and a hint string with supplemental information.

Parameters

  • applicationId: The application identifier owning the activation.
  • licenseKey: The license key (UUID v4) used to identify the activation. Use the key obtained from generateLicenseKey or provided by Magic Lane.
  • productId: The product identifier to activate. Defaults to ProductID.core.
  • onComplete: Callback invoked on completion. The callback receives:

Returns

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

Also see:

Implementation

static TaskHandler? activate({
  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',
    'activate',
    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);
}