sendDeviceSignature static method

Future<String?> sendDeviceSignature(
  1. String screenName
)

Implementation

static Future<String?> sendDeviceSignature(String screenName) async {
  try {
    final result = await _channel
        .invokeMethod(
      "sendDeviceSignature",
      {"screenName": screenName},
    )
        .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;
    }

    // iOS old SDK → bool
    if (result is bool) {
      if (!result) {
        latestError = const ShieldError("0", "sendDeviceSignature failed");
        return null;
      }
      return await sessionId;
    }

    return result?.toString();
  } 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;
  }
}