fetchDeferredDeeplinkData static method

Future<NiceDeeplinksData> fetchDeferredDeeplinkData(
  1. String fingerprint
)

Implementation

static Future<NiceDeeplinksData> fetchDeferredDeeplinkData(String fingerprint) async {
  if (_apiKey == null) {
    throw StateError("NiceDeeplinks not initialized. Call NiceDeeplinks.initialize() first.");
  }

  final uri = Uri.parse("$_baseUrl/dynamic-link/deferred").replace(
    queryParameters: {
      "fingerprint": fingerprint,
    },
  );
  final response = await http.get(
    uri,
    headers: {
      "Api-Key": _apiKey!,
      "Tenant-Id": _tenantId!,
    },
  );
  if (response.statusCode >= 200 && response.statusCode < 300) {
    final data = jsonDecode(response.body) as Map<String, dynamic>;
    return NiceDeeplinksData(link: Uri.parse((data["deepLinkUrl"] as String).replaceFirst("/#", "")));
  } else {
    throw Exception("Failed to fetch deeplink data");
  }
}