deliverDeferredDeepLink method

Future<void> deliverDeferredDeepLink(
  1. DeepLinkData? deepLinkData, {
  2. bool isNewInstall = true,
})

Delivers deferred deep link data to all registered callbacks

  • deepLinkData: Deep link data from attribution, null for organic
  • isNewInstall: Whether the install was reported on this launch, rather than loaded from the cache. Only that launch delivers the deferred deep link and records it as an open for last-click attribution; a later launch delivers nothing, and the attribution stays available from LinkForty.getInstallData().

Implementation

Future<void> deliverDeferredDeepLink(
  DeepLinkData? deepLinkData, {
  bool isNewInstall = true,
}) async {
  if (!isNewInstall) return;

  _cachedDeferredDeepLink = deepLinkData;
  _deferredDeepLinkDelivered = true;

  // Pin last-click attribution to this deferred (install) open, unless a
  // direct open has already been recorded: that is the newer of the two.
  if (!_directOpenRecorded) {
    await _attributionContext?.recordDeepLinkOpen(
      linkId: deepLinkData?.linkId,
    );
  }

  LinkFortyLogger.log(
    'Delivering deferred deep link: ${deepLinkData?.shortCode ?? "organic"}',
  );

  // Create a snapshot of callbacks to avoid modification during iteration
  final callbacks = List<DeferredDeepLinkCallback>.from(
    _deferredDeepLinkCallbacks,
  );

  // Invoke all callbacks
  for (final callback in callbacks) {
    callback(deepLinkData);
  }
}