getVisitorId static method

Future<String?> getVisitorId({
  1. JSObject? tags,
  2. String? linkedId,
  3. int? timeoutMs,
})

Returns the visitorId generated by the native Fingerprint Pro client Support tags Support linkedId Support timeoutMs Throws a FingerprintProError if identification request fails for any reason

Implementation

static Future<String?> getVisitorId(
    {JSObject? tags, String? linkedId, int? timeoutMs}) async {
  if (!_isInitialized) {
    throw Exception(
        'You need to initialize the FPJS Client first by calling the "initFpjs" method');
  }

  try {
    FingerprintJSAgent fp = await (_fpPromise as Future<FingerprintJSAgent>);
    var result = await fp
        .get(FingerprintJSGetOptions(
            linkedId: linkedId, tag: tags, timeout: timeoutMs))
        .toDart;
    return result.visitorId;
  } catch (e) {
    if (e is WebException) {
      throw unwrapWebError(e);
    } else {
      throw UnknownError(e.toString());
    }
  }
}