createLink method

Future<String?> createLink(
  1. String data
)

Creates a new deep link. @param data The content to share through the link. This can be an absolute URL, relative URL, query parameters, JSON object, plain text, or any other string-formatted data.

Implementation

Future<String?> createLink(String data) async {
  assert(_appId != null, ErrorStrings.serviceUninitialized);

  if (_appId == null) return null;

  final res = await _apiService.request(
    method: ApiMethod.post,
    endpoint: ApiEndpoints.links,
    body: {ApiKeys.appId: _appId, ApiKeys.data: data},
  );

  if (!res.success) return null;

  try {
    final id = res.data[ApiKeys.data][ApiKeys.id];
    return '${ApiConstants.webBaseURL}/$_appId/$id';
  } catch (e, st) {
    _logService.logError(e, st);
    return null;
  }
}