All Projects → smstuebe → Xamarin Fingerprint

smstuebe / Xamarin Fingerprint

Licence: ms-pl
Xamarin and MvvMCross plugin for authenticate a user via fingerprint sensor

Labels

Projects that are alternatives of or similar to Xamarin Fingerprint

Xreader
XML, NEWS, RSS & Scrapping Reader maked in Xamarin, for educational purpose.
Stars: ✭ 259 (-26.84%)
Mutual labels:  xamarin
Jitterphysics
A cross-platform, realtime physics engine for all .NET apps.
Stars: ✭ 277 (-21.75%)
Mutual labels:  xamarin
Open Source Xamarin Apps
📱 Collaborative List of Open Source Xamarin Apps
Stars: ✭ 318 (-10.17%)
Mutual labels:  xamarin
Contextmenu
ContextView for Xamarin.Forms
Stars: ✭ 271 (-23.45%)
Mutual labels:  xamarin
Arcgis Runtime Samples Dotnet
Sample code for ArcGIS Runtime SDK for .NET – UWP, WPF, Xamarin.Android, Xamarin.iOS, and Xamarin.Forms
Stars: ✭ 274 (-22.6%)
Mutual labels:  xamarin
Msbuildsdkextras
Extra properties for MSBuild SDK projects
Stars: ✭ 288 (-18.64%)
Mutual labels:  xamarin
linphone-xamarin
Linphone.org mirror for linphone-xamarin (git://git.linphone.org/linphone-xamarin.git)
Stars: ✭ 23 (-93.5%)
Mutual labels:  xamarin
Puremvc Csharp Standard Framework
PureMVC Standard Framework for C#
Stars: ✭ 335 (-5.37%)
Mutual labels:  xamarin
Mvvmcross Samples
Tutorials and samples for MvvmCross: The .NET MVVM framework for cross-platform solutions.
Stars: ✭ 277 (-21.75%)
Mutual labels:  xamarin
Messagepack Csharp
Extremely Fast MessagePack Serializer for C#(.NET, .NET Core, Unity, Xamarin). / msgpack.org[C#]
Stars: ✭ 3,668 (+936.16%)
Mutual labels:  xamarin
Parse Sdk Dotnet
Parse SDK for .NET, Xamarin, Unity.
Stars: ✭ 272 (-23.16%)
Mutual labels:  xamarin
Aiforms.settingsview
SettingsView for Xamarin.Forms
Stars: ✭ 274 (-22.6%)
Mutual labels:  xamarin
Gray hat csharp code
This repository contains full code examples from the book Gray Hat C#
Stars: ✭ 301 (-14.97%)
Mutual labels:  xamarin
Fusillade
An opinionated HTTP library for Mobile Development
Stars: ✭ 269 (-24.01%)
Mutual labels:  xamarin
Eshoponcontainers
Cross-platform .NET sample microservices and container based application that runs on Linux Windows and macOS. Powered by .NET 6, Docker Containers and Azure Kubernetes Services. Supports Visual Studio, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
Stars: ✭ 19,397 (+5379.38%)
Mutual labels:  xamarin
Geolocatorplugin
Geolocation plugin for Xamarin and Windows
Stars: ✭ 257 (-27.4%)
Mutual labels:  xamarin
Tensorflowsharp
TensorFlow API for .NET languages
Stars: ✭ 3,027 (+755.08%)
Mutual labels:  xamarin
Mvvmcross
The .NET MVVM framework for cross-platform solutions, including Xamarin.iOS, Xamarin.Android, Windows and Mac.
Stars: ✭ 3,594 (+915.25%)
Mutual labels:  xamarin
Prism Samples Forms
Samples that demonstrate how to use various Prism features with Xamarin.Forms
Stars: ✭ 327 (-7.63%)
Mutual labels:  xamarin
Firebasepushnotificationplugin
Firebase Push Notification Plugin for Xamarin iOS and Android
Stars: ✭ 307 (-13.28%)
Mutual labels:  xamarin

Biometric / Fingerprint plugin for Xamarin

Xamarin and MvvMCross plugin for accessing the fingerprint, Face ID or other biometric sensors.

Type Stable Pre release
vanilla NuGet NuGet
MvvmCross NuGet NuGet

Changelog

Support

If you like the quality and code you can support me

  • Donate

Thanks!

The plugin supports the listed platforms.

Platform Version
Xamarin.Android 6.0
Xamarin.iOS 8.0
Xamarin.Mac 10.12
Windows UWP 10

Setup

iOS

Add NSFaceIDUsageDescription to your Info.plist to describe the reason your app uses Face ID. (see Documentation). Otherwise the App will crash when you start a Face ID authentication on iOS 11.3+.

<key>NSFaceIDUsageDescription</key>
<string>Need your face to unlock secrets!</string>

Android

Set Target SDK version

The target SDK version has to be >= 6.0. I recomment to use always the latest stable SDK version, if possible. You can set the target SDK version in your Android project properties.

Install Android X Migration

Since version 2, this plugin uses Android X. You have to install Xamarin.AndroidX.Migration in your Android project.

Request the permission in AndroidManifest.xml

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

Set the resolver of the current Activity

Skip this, if you use the MvvMCross Plugin or don't use the dialog.

We need the current activity to display the dialog. You can use the Current Activity Plugin from James Montemagno or implement your own functionality to retrieve the current activity. See Sample App for details.

CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);

Usage

Example

vanilla

var request = new AuthenticationRequestConfiguration ("Prove you have fingers!", "Because without it you can't have access");
var result = await CrossFingerprint.Current.AuthenticateAsync(request);
if (result.Authenticated)
{
    // do secret stuff :)
}
else
{
    // not allowed to do secret stuff :(
}

using MvvMCross

var fpService = Mvx.Resolve<IFingerprint>(); // or use dependency injection and inject IFingerprint

var request = new AuthenticationRequestConfiguration ("Prove you have mvx fingers!", "Because without it you can't have access");
var result = await fpService.AuthenticateAsync(request);
if (result.Authenticated)
{
    // do secret stuff :)
}
else
{
    // not allowed to do secret stuff :(
}

mocking in unit tests

//Create mock with LigthMock (http://www.lightinject.net/)
var mockFingerprintContext = new MockContext<IFingerprint>();
var mockFingerprint = new CrossFingerprintMock(mockFingerprintContext);

mockFingerprintContext.Current = mockFingerprint;

Detailed Tutorial by @jfversluis

Youtube: Secure Your Xamarin App with Fingerprint or Face Recognition (click thumbnail)

Secure Your Xamarin App with Fingerprint or Face Recognition

API

The API is defined by the IFingerprint interface:

/// <summary>
/// Checks the availability of fingerprint authentication.
/// Checks are performed in this order:
/// 1. API supports accessing the fingerprint sensor
/// 2. Permission for accessint the fingerprint sensor granted
/// 3. Device has sensor
/// 4. Fingerprint has been enrolled
/// <see cref="FingerprintAvailability.Unknown"/> will be returned if the check failed
/// with some other platform specific reason.
/// </summary>
/// <param name="allowAlternativeAuthentication">
/// En-/Disables the use of the PIN / Passwort as fallback.
/// Supported Platforms: iOS, Mac
/// Default: false
/// </param>
Task<FingerprintAvailability> GetAvailabilityAsync(bool allowAlternativeAuthentication = false);

/// <summary>
/// Checks if <see cref="GetAvailabilityAsync"/> returns <see cref="FingerprintAvailability.Available"/>.
/// </summary>
/// <param name="allowAlternativeAuthentication">
/// En-/Disables the use of the PIN / Passwort as fallback.
/// Supported Platforms: iOS, Mac
/// Default: false
/// </param>
/// <returns><c>true</c> if Available, else <c>false</c></returns>
Task<bool> IsAvailableAsync(bool allowAlternativeAuthentication = false);

/// <summary>
/// Requests the authentication.
/// </summary>
/// <param name="reason">Reason for the fingerprint authentication request. Displayed to the user.</param>
/// <param name="cancellationToken">Token used to cancel the operation.</param>
/// <returns>Authentication result</returns>
Task<FingerprintAuthenticationResult> AuthenticateAsync(string reason, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Requests the authentication.
/// </summary>
/// <param name="authRequestConfig">Configuration of the dialog that is displayed to the user.</param>
/// <param name="cancellationToken">Token used to cancel the operation.</param>
/// <returns>Authentication result</returns>
Task<FingerprintAuthenticationResult> AuthenticateAsync(AuthenticationRequestConfiguration authRequestConfig, CancellationToken cancellationToken = default(CancellationToken));

The returned FingerprintAuthenticationResult contains information about the authentication.

/// <summary>
/// Indicatates whether the authentication was successful or not.
/// </summary>
public bool Authenticated { get { return Status == FingerprintAuthenticationResultStatus.Succeeded; } }

/// <summary>
/// Detailed information of the authentication.
/// </summary>
public FingerprintAuthenticationResultStatus Status { get; set; }

/// <summary>
/// Reason for the unsucessful authentication.
/// </summary>
public string ErrorMessage { get; set; }

iOS

Limitations

You can't create a custom dialog. The standard iOS Dialog will be shown.

iOS 9+ only
  • cancelable programmatically with passed CancellationToken
  • custom fallback button title
iOS 10+ only
  • custom cancel button title

UWP

Limitations

You can't use the alternative authentication method.

Testing on Simulators

iOS

Controlling the sensor on the iOS Simulator

With the Hardware menu you can

  • Toggle the enrollment status
  • Trigger valid ( M) and invalid ( N) fingerprint sensor events

Android

  • start the emulator (Android >= 6.0)
  • open the settings app
  • go to Security > Fingerprint, then follow the enrollment instructions
  • when it asks for touch
  • open command prompt
  • telnet 127.0.0.1 <emulator-id> (adb devices prints "emulator-<emulator-id>")
  • finger touch 1
  • finger touch 1

Sending fingerprint sensor events for testing the plugin can be done with the telnet commands, too.

Note for Windows users: You have to enable telnet: Programs and Features > Add Windows Feature > Telnet Client

Nice to know

Android code shrinker (Proguard & r8)

If you use the plugin with Link all, Release Mode and ProGuard/r8 enabled, you may have to do the following:

  1. Create a proguard.cfg file in your android project and add the following:
    -dontwarn com.samsung.**
    -keep class com.samsung.** {*;}
  1. Include it to your project
  2. Properties > Build Action > ProguardConfiguration

Contribution

+

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].