authenticateCrossDeviceSession method

Future<void> authenticateCrossDeviceSession(
  1. CrossDeviceSession crossDeviceSession,
  2. User user,
  3. String pin
)

Authenticates the user on another device or application using CrossDeviceSession.

Parameters:

  • crossDeviceSession: The details for the authentication operation.
  • user: The User to authenticate.
  • pin: The user's PIN.

Throws AuthenticationException if the authentication process fails for any reason (e.g., incorrect PIN, revoked user).

Implementation

Future<void> authenticateCrossDeviceSession(CrossDeviceSession crossDeviceSession, User user, String pin) async {
  try {
    final mUser = user._toMUser();
    final mCrossDeviceSession = crossDeviceSession._toMCrossDeviceSession();

    return await _sdk.authenticateCrossDeviceSession(mCrossDeviceSession, mUser, pin);
  } on PlatformException catch(e) {
    final exceptionCode = e._getExceptionCode();
    if (exceptionCode is MAuthenticationExceptionCode) {
      throw AuthenticationException._create(
        exceptionCode.toAuthenticationExceptionCode(),
        e.details["error"]
      );
    } else {
      rethrow;
    }
  }
}