authenticate static method

Future<bool> authenticate()

Implementation

static Future<bool> authenticate() async {
  try {
    if (!await _canAuthenticate()) {
      return false;
    }
    final bioType = await _getAvailableBiometrics();
    if (bioType.contains(BiometricType.face)) {
      return await _auth.authenticate(
        localizedReason: 'the reason you want to use face id',
        authMessages: const <AuthMessages>[
          IOSAuthMessages(cancelButton: 'No thanks'),
          AndroidAuthMessages(
            signInTitle: 'Allow biometric',
            cancelButton: 'No Thanks',
          ),
        ],
        options: const AuthenticationOptions(stickyAuth: true),
      );
    } else if (bioType.contains(BiometricType.fingerprint)) {
      return await _auth.authenticate(
        localizedReason: 'the reason you want to use fingerprint',
        authMessages: const <AuthMessages>[
          IOSAuthMessages(cancelButton: 'No thanks'),
          AndroidAuthMessages(
            signInTitle: 'Allow biometric',
            cancelButton: 'No Thanks',
          ),
        ],
        options: const AuthenticationOptions(stickyAuth: true),
      );
    } else {
      return false;
    }
  } catch (e) {
    return false;
  }
}