Android Standalone App LocalAuthentication

Hello,

I’m trying to use Expo.LocalAuthentication for fingerprint and/or FaceID. It works fine on iOS, it works fine on Android in Expo but if I build a standalone app it doesn’t work anymore Android (still fine on iOS though)…
“sdkVersion”: “32.0.0”

When doing:

let compatible = await Expo.LocalAuthentication.hasHardwareAsync();
let got = await Expo.LocalAuthentication.isEnrolledAsync();

Neither of those calls returns (tested them in different order). What could be the cause? I’m using it fine on another app with the same sdk, so I’m really lost at the moment.

Hey @davidthink,

I’m thinking this may have to do with your importing of the module. As of SDK32, you can no longer use import Expo from 'expo. You’ll either need to import the individual module via import {LocalAuthentication} from 'expo' or if you still want to import the entire SDK you’ll use import * as Expo from 'expo'.

Let me know if that isn’t the case and it’s still not working.

Cheers,
Adam

Hello @adamjnav !

No, unfortunately. I’m importing it like you said, import * as Expo from ‘expo’.

@adamjnav

I found the problem. I was in SDK31 until two days ago, and I was already trying to import my project onto the PlayStore. The thing is, I had to set android.permissions: [] in order to get rid of the READ_SMS warning. Later, uploading a file in my app didn’t function anymore either, so I had to add

  "permissions": [
    "CAMERA",
    "READ_INTERNAL_STORAGE",
    "READ_EXTERNAL_STORAGE",
    "WRITE_EXTERNAL_STORAGE"
  ]

to app.json, then the upload was working but not fingerprint. Then I tried to update to SDK32. Now I removed all the permissions in Android side of app.json and it works. I think the READ_SMS permissions do not affect SDK32 so I’ll be ok, but what permissions for LocalAuthentication is missing in Android, if I wanted to put only the ones I need?

@adamjnav
Another problem: It seems that it works only once on Android devices. If I try to relaunch the code where I do check if it’s the good fingerprint, it never returns.

let success = await Expo.LocalAuthentication.authenticateAsync();
--------------- Never go past here after one wrong attempt, works fine the first time.

if (success.success) {
            NavigationUtils.goToNavigationScreen(this.props);
        }
        else{
            this.setState({finger:'Wrong biometrics'})
            console.log("Wrong")
        }

Does the problem come from expo?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.