在 flutter 应用程序中为 iOS 或 Android 自定义 Native Alert 对话框以实现 Face Id 实现
Customize The Native Alert dialog in flutter applicaton for iOS or Android for Face Id implementation
下面是成功实现的flutter应用中的生物识别访问认证方法。
如果发生错误,它会显示一个警告对话框,如 iOS 应用程序中的图像所示,我想自定义此警告对话框,我该怎么做?
AlertBox 图片
此警告对话框仅在 useErrorDialogs
设置为 true
时显示,如下面的代码所示。
引用自Face Id Lock Implementation in Flutter
Future<void> _authenticateUser() async {
bool isAuthenticated = false;
try {
isAuthenticated = await _localAuthentication.authenticateWithBiometrics(
localizedReason:
"Please authenticate to view your transaction overview",
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
isAuthenticated
? print('User is authenticated!')
: print('User is not authenticated.');
if (isAuthenticated) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => TransactionScreen(),
),
);
}
}
你无法改变它。出于安全原因,整个生物识别身份验证过程由 iOS 在您的应用程序外部处理。
下面是成功实现的flutter应用中的生物识别访问认证方法。 如果发生错误,它会显示一个警告对话框,如 iOS 应用程序中的图像所示,我想自定义此警告对话框,我该怎么做?
AlertBox 图片
此警告对话框仅在 useErrorDialogs
设置为 true
时显示,如下面的代码所示。
引用自Face Id Lock Implementation in Flutter
Future<void> _authenticateUser() async {
bool isAuthenticated = false;
try {
isAuthenticated = await _localAuthentication.authenticateWithBiometrics(
localizedReason:
"Please authenticate to view your transaction overview",
useErrorDialogs: true,
stickyAuth: true,
);
} on PlatformException catch (e) {
print(e);
}
if (!mounted) return;
isAuthenticated
? print('User is authenticated!')
: print('User is not authenticated.');
if (isAuthenticated) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => TransactionScreen(),
),
);
}
}
你无法改变它。出于安全原因,整个生物识别身份验证过程由 iOS 在您的应用程序外部处理。