yobydev
yobydev

Reputation: 31

Expo Local Authentication Face ID Doesn't Work

I installed the "expo-local-authentication" library into my Expo project. I made the necessary adjustments in app.json for FaceId. When logging in, it does not ask for FaceId, it asks for the phone password. I also get the error on console, which I will share below.

Code:

useEffect(() => {
    (async () => {
      const compatible = await LocalAuthentication.hasHardwareAsync();
      setIsBiometricSupported(compatible);
    })();

    if (isBiometricSupported) {
      onAuthenticate();
    }
  });

  function onAuthenticate() {
    const auth = LocalAuthentication.authenticateAsync({
      promptMessage: "Authenticate with Touch ID",
      fallbackLabel: "Enter Password",
    });
    auth.then((result) => {
      setIsAuthenticated(result.success);
      console.log(result);
    });
  }

console: LOG {"error": "system_cancel", "success": false, "warning": "FaceID is available but has not been configured. To enable FaceID, provide "NSFaceIDUsageDescription"."}

My phone screen

I would appreciate it if someone could share with me how to go about using FaceId at Expo.

I added NSFaceIDUsageDescription field in App.json.

 "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.goldtagvendorpanel.app",
      "userInterfaceStyle": "automatic",
      "infoPlist": {
        "NSFaceIDUsageDescription": "Uygulamanızda Face ID kullanmak için izin gerekiyor"
      }
    }, 

Upvotes: 2

Views: 1088

Answers (1)

Archimedes4
Archimedes4

Reputation: 1

Add a plugin like

 "plugins": [
  [
    "expo-local-authentication",
    {
      "faceIDPermission": "Allow $(PRODUCT_NAME) to use Face ID."
    }
  ]
]

There is no need for info plist and it isn't wise to call the local auth function on every re render. A working repo can be found at https://github.com/Archimedes4/LocalAuth

Upvotes: 0

Related Questions