handleDeepLink method

Future<void> handleDeepLink(
  1. Uri uri
)

Resolves the provided uri to extract DeepLinkData.

It first attempts to resolve the URL via the LinkForty backend to get full campaign metadata. If the network request fails or the SDK is not configured for server-side resolution, it falls back to parsing the URL locally.

Implementation

Future<void> handleDeepLink(Uri uri) async {
  LinkFortyLogger.log('Handling deep link: $uri');

  final localData = URLParser.parseDeepLink(uri);

  final resolvedData =
      (_networkManager != null && _fingerprintCollector != null)
          ? await _resolveUrl(uri, fallback: localData)
          : localData;

  final callbacks = List<DeepLinkCallback>.from(_deepLinkCallbacks);

  if (resolvedData != null) {
    LinkFortyLogger.log('Parsed deep link: $resolvedData');
  } else {
    LinkFortyLogger.log('Failed to parse deep link URL');
  }

  for (final callback in callbacks) {
    callback(uri, resolvedData);
  }
}