sendDeviceSignature static method

Future<String?> sendDeviceSignature(
  1. String screenName, {
  2. String? userId,
})

Implementation

static Future<String?> sendDeviceSignature(
    String screenName, {
      String? userId,
    }) async {
  try {
    final args = <String, dynamic>{
      "screenName": screenName,
    };

    if (userId != null && userId.isNotEmpty) {
      args["userId"] = userId;
    }

    final String? result = await _channel
        .invokeMethod<String>(
      "sendDeviceSignature",
      args,
    )
        .timeout(const Duration(seconds: 30), onTimeout: () => null);

    latestError = null;

    // timeout case
    if (result == null) {
      latestError = const ShieldError(
        "0",
        "sendDeviceSignature timed out or failed",
      );
      return null;
    }

    return result;
  } on PlatformException catch (e, s) {
    _internalLog("sendDeviceSignature failed", e, s);
    latestError = ShieldError(
      e.code,
      e.message ?? e.details?.toString() ?? "Unknown error",
      exception: e.details?.toString(),
    );
    return null;
  } catch (e, s) {
    _internalLog("sendDeviceSignature failed", e, s);
    latestError = ShieldError(
      "0",
      e.toString().isNotEmpty
          ? e.toString()
          : (s.toString().isNotEmpty ? s.toString() : "Unknown error"),
    );
    return null;
  }
}