패키지, 저장소 및 앱 카테고리 검색

패키지 상세v2.2.0

flutter_local_auth_invisible

Android 및 iOS 장치 인증 센서(지문 리더 및 터치 ID 등)용 플러터 플러그인으로, Android에서는 표시되는 대화 상자가 없습니다.

AndroidiOS
30일 다운로드
63
좋아요
54
Pub 점수
130

패키지 설치

flutter pub add flutter_local_auth_invisible

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Android 및 iOS에서 지문 스캐너와 Touch ID와 같은 장치 센서를 사용하여 생체 인식 인증을 가능하게 하는 플러터 플러그인입니다. 표준 구현과 달리 안드로이드에서는 인증 중에 보이는 대화상자가 나타나지 않는 '보이지 않는 인증'을 지원하여 원활한 사용자 경험을 제공합니다. 네이티브 생체 인식 API와 통합되어 백그라운드 또는 침묵형 인증이 필요한 앱에 적합합니다. 이 플러그인은 dvaplus.eu에서 유지 관리되며 커스터마이징을 위해 GitHub에서 이용 가능합니다.

사용 사례

  • 사일런트 생체 인식 로그인
  • 보안 앱에서의 백그라운드 인증
  • UI 프롬프트 없이 원활한 앱 잠금 해제
  • 민감한 데이터 접근을 위한 강화된 보안
  • 인증 워크플로우에서 마찰 감소

주요 기능

  • Android에서의 비시각적 인증
  • 터치 ID 및 지문 센서 지원
  • 크로스 플랫폼 호환성 (Android 및 iOS)
  • 최소한의 UI 방해
  • 안전한 네이티브 통합
  • GitHub의 오픈소스 코드

적합한 대상

  • 은밀한 생체 인증이 필요한 앱
  • 최소한의 UI 영향을 원하는 개발자
  • 보안 중심 애플리케이션
  • 자주 인증이 필요한 모바일 앱
  • 맞춤형 인증 흐름이 필요한 프로젝트

고려 사항

  • 제한된 시각적 접근은 사용자를 혼란스럽게 할 수 있습니다
  • 실패한 시도를 신중하게 처리해야 합니다
  • 피드백 부족으로 인해 모든 사용 사례에 적합하지 않습니다
  • 안드로이드 전용 동작은 장치 지원에 따라 달라집니다
  • 비표시 인증을 사용할 때 사용자 신뢰와 투명성은 핵심적입니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_local_auth_invisible

This Flutter plugin is a fork of the official local_auth plugin and provides means to perform local, on-device authentication of the user.

This means referring to biometric authentication on iOS (Touch ID or lock code) and the fingerprint APIs on Android (introduced in Android 6.0).

On Android this plugin suppresses the standard system-wide fingerprint authentication dialog, so you are free to implement your own UI.

Usage in Dart

Import the relevant file:

import 'package:flutter_local_auth_invisible/flutter_local_auth_invisible.dart';

To check whether there is local authentication available on this device or not, call canCheckBiometrics:

bool canCheckBiometrics = await LocalAuthentication.canCheckBiometrics;

Currently the following biometric types are implemented:

  • BiometricType.face
  • BiometricType.fingerprint

To get a list of enrolled biometrics, call getAvailableBiometrics:

List<BiometricType> availableBiometrics = await LocalAuthentication.getAvailableBiometrics();
if (availableBiometrics.contains(BiometricType.face)) {
  // Face ID.
} else if (availableBiometrics.contains(BiometricType.fingerprint)) {
  // Touch ID.
}

We have default dialogs with an 'OK' button to show authentication error messages for the following 2 cases:

  1. Passcode/PIN/Pattern Not Set. The user has not yet configured a passcode on iOS or PIN/pattern on Android.
  2. Touch ID/Fingerprint Not Enrolled. The user has not enrolled any fingerprints on the device.

Which means, if there's no fingerprint on the user's device, a dialog with instructions will pop up to let the user set up fingerprint. If the user clicks 'OK' button, it will return 'false'.

Use the exported APIs to trigger local authentication with default dialogs:

bool didAuthenticate =
  await LocalAuthentication.authenticateWithBiometrics(
    localizedReason: 'Please authenticate to show account balance',
  );

If you don't want to use the default dialogs, call this API with 'useErrorDialogs = false'. In this case, it will throw the error message back and you need to handle them in your dart code:

bool didAuthenticate =
  await LocalAuthentication.authenticateWithBiometrics(
    localizedReason: 'Please authenticate to show account balance',
    useErrorDialogs: false,
  );

You can use our default dialog messages, or you can use your own messages by passing in IOSAuthMessages and AndroidAuthMessages:

import 'package:local_auth/auth_strings.dart';

const iosStrings = const IOSAuthMessages(
  cancelButton: 'cancel',
  goToSettingsButton: 'settings',
  goToSettingsDescription: 'Please set up your Touch ID.',
  lockOut: 'Please reenable your Touch ID',
);
await LocalAuthentication.authenticateWithBiometrics(
  localizedReason: 'Please authenticate to show account balance',
  iOSAuthStrings: iosStrings,
  useErrorDialogs: false,
);

If needed, you can manually stop authentication for Android:

void _cancelAuthentication() {
    LocalAuthentication.stopAuthentication();
}

Look here for the complete example.

Exceptions

There are 4 types of exceptions: PasscodeNotSet, NotEnrolled, NotAvailable and OtherOperatingSystem. They are wrapped in LocalAuthenticationError class. You can catch the exception and handle them by different types. For example:

import 'package:flutter/services.dart';
import 'package:local_auth/error_codes.dart' as auth_error;

try {
  bool didAuthenticate = await LocalAuthentication.authenticate(
    localizedReason: 'Please authenticate to show account balance',
  );
} on PlatformException catch (e) {
  if (e.code == auth_error.notAvailable) {
    // Handle this exception here.
  }
}

iOS Integration

Note that this plugin works with both TouchID and FaceID. However, to use the latter, you need to also add:

<key>NSFaceIDUsageDescription</key>
<string>Why is my app authenticating using face id?</string>

to your Info.plist file. Failure to do so results in a dialog that tells the user your app has not been updated to use TouchID.

Android Integration

Note that local_auth plugin requires the use of a FragmentActivity as opposed to Activity. This can be easily done by switching to use FlutterFragmentActivity as opposed to FlutterActivity in your manifest (or your own Activity class if you are extending the base class).

Update your MainActivity.java:

import android.os.Bundle;
import io.flutter.app.FlutterFragmentActivity;
import io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin;
import io.flutter.plugins.localauth.LocalAuthPlugin;

public class MainActivity extends FlutterFragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FlutterAndroidLifecyclePlugin.registerWith(
                registrarFor(
                        "io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin"));
        LocalAuthPlugin.registerWith(registrarFor("io.flutter.plugins.localauth.LocalAuthPlugin"));
    }
}

OR

Update your MainActivity.kt:

import io.flutter.embedding.android.FlutterFragmentActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterFragmentActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }
}

Update your project's AndroidManifest.xml file to include the USE_FINGERPRINT permissions:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example.app">
  <uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<manifest>

Sticky Auth

You can set the stickyAuth option on the plugin to true so that plugin does not return failure if the app is put to background by the system. This might happen if the user receives a phone call before they get a chance to authenticate. With stickyAuth set to false, this would result in plugin returning failure result to the Dart app. If set to true, the plugin will retry authenticating when the app resumes.

카테고리

의존성

의존성 목록 4 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.