getAttributionData static method

Future<AttributionData?> getAttributionData()

Get attribution data from native SDK

Implementation

static Future<AttributionData?> getAttributionData() async {
  try {
    final result = await _channel.invokeMethod('getAttributionData');

    if (result == null) {
      developer.log('Attribution data result is null', name: packageName);
      return null;
    }

    // Handle empty map case (when attribution data is not available)
    if (result is Map && result.isEmpty) {
      developer.log('Attribution data result is empty', name: packageName);
      return null;
    }

    // Recursively convert the result to Map<String, dynamic>
    final Map<String, dynamic> attributionMap = _convertToStringDynamicMap(result);

    return AttributionData.fromJSON(attributionMap);
  } on PlatformException catch (e) {
    developer.log('Failed to get attribution data: ${e.message}',
        error: e, name: packageName);
    rethrow;
  } catch (e) {
    developer.log('Failed to parse attribution data: ${e.toString()}',
        error: e, name: packageName);
    rethrow;
  }
}