Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
49 lines (40 sloc) 1.32 KB
published title date author layout permalink tags
true
How to enable Face ID on Xamarin.iOS
2019-01-15 21:58:11 UTC
fabiocozzolino
post
/enable-face-id-on-xamarin-ios/
Xamarin
iOS

With iPhone X, Apple release a new biometric authentication way: Face ID. Like others things, you need to obtain access to that feature. To achieve this, you must add the NSFaceIDUsageDescription key to the info.plist file:

Enable Face ID

The, optional, description will be good if you want to explain why your app request the ability to authenticate with Face ID.

After that, you will be able to use Face ID authentication:

var context = new LAContext();
if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out NSError authError))
{
    var replyHandler = new LAContextReplyHandler((success, error) =>
    {
        InvokeOnMainThread(() =>
        {
            if (success)
            {
                // user authenticated
            }
            else
            {
                // user not authenticated
            }
        });
    });
    context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, "Authenticate", replyHandler);
}

the above code will works for both Touch ID and Face ID.

Enjoy!

You can’t perform that action at this time.