triggerCampaign method

CampaignPresentation triggerCampaign(
  1. String campaignKey, {
  2. Map<String, String>? variables,
})

Delivers a campaign the host app asked for by key, with no CEP involved — parity with Android/iOS triggerCampaign. Digia-internal: not on the public Digia API. Mints a host:<uuid> id, since no CEP supplies one.

Implementation

CampaignPresentation triggerCampaign(
  String campaignKey, {
  Map<String, String>? variables,
}) {
  const driver = HostDriver();
  final payload = CEPTriggerPayload(
    cepCampaignId: 'host:${const Uuid().v4()}',
    cepMetadata: const <String, dynamic>{},
    campaignKey: campaignKey.trim(),
    variables: variables,
  );
  final controller = _coordinator.open(payload, owner: driver.owner);
  // Before the state gate, exactly as deliver() does: a trigger refused
  // outright must still read on the timeline as having arrived.
  observeDelivery(controller);
  final drop = _preReadyDrop();
  if (drop == null) {
    _routeDelivered(controller, driver);
  } else {
    final (reason, detail) = drop;
    _log.w('Dropped — $detail', campaign: payload.campaignKey);
    controller.settle(PresentationDropped(reason: reason, detail: detail));
  }
  return controller.presentation;
}