Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JimmyPun610/Plugin.XF.TouchID
This is the library for Xamarin Form to use Biometric ID to do the local authentication
https://github.com/JimmyPun610/Plugin.XF.TouchID
biometric-authentication faceid faceid-authentication fingerprint fingerprint-authentication touch touchid touchid-authentication xamarin-form xamarin-forms
Last synced: 30 days ago
JSON representation
This is the library for Xamarin Form to use Biometric ID to do the local authentication
- Host: GitHub
- URL: https://github.com/JimmyPun610/Plugin.XF.TouchID
- Owner: JimmyPun610
- License: mit
- Created: 2019-03-08T04:29:34.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T10:01:26.000Z (over 2 years ago)
- Last Synced: 2024-11-06T22:52:16.331Z (about 1 month ago)
- Topics: biometric-authentication, faceid, faceid-authentication, fingerprint, fingerprint-authentication, touch, touchid, touchid-authentication, xamarin-form, xamarin-forms
- Language: C#
- Homepage:
- Size: 1.54 MB
- Stars: 18
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xamarin-forms - Plugin.XF.TouchID ★22
README
# Plugin.XF.TouchID
This project provides a easy way to call biometric authentication (Face / Fingerprint) function in Xamarin Forms### Support
#### Android 6 - 12 TouchID (Target API Level 31)
#### iOS 10+ FaceID and TouchID### Release notes
#### Version 2.2
1. Add Support to Android 12### Nuget installation
#### Install to your Xamarin Project
```
Install-Package Plugin.XF.TouchID
```#### Build Status
##### Android [![Build status](https://build.appcenter.ms/v0.1/apps/2aaea9c6-9358-481a-90aa-8d1f8cbaf0b7/branches/master/badge)](https://github.com/JimmyPun610/Plugin.XF.TouchID)
##### iOS### iOS Guide
1. In AppDelegate.cs
```C#
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
//Init the library
Plugin.XF.TouchID.TouchID.Init();
return base.FinishedLaunching(app, options);
```
2. In your info.plist, add face id permission request
```
NSFaceIDUsageDescription
Need your face to unlock secrets!
```FaceID | TouchID
------ | -----
|### Android Guide
1. Set TargetFramework as Android10.0 (Q) API Level 29
2. In MainActivity
```C#
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
//Init the library
//Use secret key, please use a unique keyname
Plugin.XF.TouchID.TouchID.Init(this, "plugin.xf.touchid.fingerprintkey");
//If you do not want to use secret key
//Plugin.XF.TouchID.TouchID.Init(this);
LoadApplication(new App());
``````C#
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
Plugin.XF.TouchID.TouchID.OnKeyguardManagerResult(data, requestCode, resultCode);
base.OnActivityResult(requestCode, resultCode, data);
}
```3. Manifest.xml add Fingerprint permission
```xml```
Android 6-8 | Android 9+
------ | -----
|### Use in Xamarin Forms
#### Check the device availabilities
```c#
// Support = 0,
// DeviceNotSecured = 1,
// NotEnrolledFinger = 2,
// HardwareNotSupport = 3,
// OSVersionNotSupport = 4,
Plugin.XF.TouchID.TouchIDStatus possible = Plugin.XF.TouchID.TouchID.IsFingerprintAuthenticationPossible());
```#### Prompt Security page for user to enroll finger or add passcode
```c#
Plugin.XF.TouchID.TouchID.PromptSecuritySettings();
```#### Do the authentication
##### Use passcode / pin for alternative authentication (Android only, iOS default allowed)
```C#
var dialogConfig = new Plugin.XF.TouchID.DialogConfiguration(dialogTitle: "Sign In", //Display in Android only
dialogDescritpion: "Detect you biometic to auth", //Display on Android and iOS(TouchID)
successAction: () =>
{
//Will fired when authentication success
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Congratulation", "You pass the authentication", "OK");
});
},
alterAuthButtonText: "Use PIN", //Display in Android only
fingerprintDialogConfiguration: new Plugin.XF.TouchID.FingerprintDialogConfiguration
{
//For Android 6-8 only
FingerprintHintString = "Touch Sensor",
FingerprintNotRecoginzedString = "Not regonized"
},
failedAction: () =>
{
//For Android 6-8 only
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Alert", "Too many unsuccessful attempt, please try again later", "OK");
});
});await Plugin.XF.TouchID.TouchID.Authenticate(dialogConfig);
```
##### Use customized action as alternative (Android only, iOS default use password)
```C#
var dialogConfig = new Plugin.XF.TouchID.DialogConfiguration(dialogTitle: "Sign In", //Display in Android only
dialogDescritpion: "Detect you biometic to auth", //Display on Android and iOS(TouchID)
successAction: () =>
{
//Will fired when authentication success
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Congratulation", "You pass the authentication", "OK");
});
},
customizedAction: new Plugin.XF.TouchID.CustomizedAction("Cancel", () =>
{
//Android Only
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Alert", "You cancel the authentication", "OK");
});
}),
fingerprintDialogConfiguration: new Plugin.XF.TouchID.FingerprintDialogConfiguration
{
//For Android 6-8 only
FingerprintHintString = "Touch Sensor",
FingerprintNotRecoginzedString = "Not regonized"
},
failedAction: () =>
{
//For Android 6-8 only
Device.BeginInvokeOnMainThread(() =>
{
DisplayAlert("Alert", "Too many unsuccessful attempt, please try again later", "OK");
});
});
await Plugin.XF.TouchID.TouchID.Authenticate(dialogConfig);
```