encodeReferrerPayload static method

String encodeReferrerPayload({
  1. required String path,
  2. Map<String, String>? params,
  3. int? timestampMs,
})

Encodes deferred payload for Play Store referrer (Base64 URL-safe JSON).

Implementation

static String encodeReferrerPayload({
  required String path,
  Map<String, String>? params,
  int? timestampMs,
}) {
  final payload = <String, dynamic>{
    'path': path,
    if (params != null && params.isNotEmpty) 'params': params,
    if (timestampMs != null) 'timestamp': timestampMs,
  };
  final json = jsonEncode(payload);
  return base64Url.encode(utf8.encode(json)).replaceAll('=', '');
}