React-native-keychain: Android does not prompt for authentication again once authentication is success V6.

Created on 15 Apr 2020  路  2Comments  路  Source: oblador/react-native-keychain

I am using this package to implement Biometric authentication on my react-native project. As i wanted to control the text on biometric prompt i upgrade from v5 to v6. But now after upgrading, on Android, its not prompting for authentication the second time once after successful authentication.

Expectation: It should propmt for authentication when ever we call getGenericPassword() method.

Most helpful comment

Hi @Raythode!

I had the same issue and solved it by adding the service config (for example com.example.appname) on both setGenericPassword() and getGenericPassword().

My code is like this:

await Keychain.setGenericPassword(email, passcode, {
      service: 'com.example.appname',
      accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
      accessible: Keychain.ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
 })

so then:

const credentials = await Keychain.getGenericPassword({
          service: 'com.example.appname',
          authenticationPrompt: {
            title: t('authenticationPromptTitle'),
            subtitle: t('authenticationPromptSubtitle'),
            description: authStore.hasFaceIdSupport
              ? t('authenticationPromptFace')
              : t('authenticationPromptFingerprint'),
            cancel: t('authenticationPromptCancel'),
          },
 })

Hope it helps.

All 2 comments

Hi @Raythode!

I had the same issue and solved it by adding the service config (for example com.example.appname) on both setGenericPassword() and getGenericPassword().

My code is like this:

await Keychain.setGenericPassword(email, passcode, {
      service: 'com.example.appname',
      accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
      accessible: Keychain.ACCESSIBLE.WHEN_PASSCODE_SET_THIS_DEVICE_ONLY,
 })

so then:

const credentials = await Keychain.getGenericPassword({
          service: 'com.example.appname',
          authenticationPrompt: {
            title: t('authenticationPromptTitle'),
            subtitle: t('authenticationPromptSubtitle'),
            description: authStore.hasFaceIdSupport
              ? t('authenticationPromptFace')
              : t('authenticationPromptFingerprint'),
            cancel: t('authenticationPromptCancel'),
          },
 })

Hope it helps.

thank you this works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renukaCIPL picture renukaCIPL  路  5Comments

donzthefonz picture donzthefonz  路  8Comments

waseemshahwan picture waseemshahwan  路  3Comments

chenxsan picture chenxsan  路  5Comments

grigorigoldman picture grigorigoldman  路  7Comments