react-native-touch-id icon indicating copy to clipboard operation
react-native-touch-id copied to clipboard

[iOS] : Support Fallback along with Fingerprint.

Open pawankhadpe opened this issue 5 years ago • 8 comments

I had an requirement in my app to support Fallback for passcode if fingerprint is not identified or user prefers to use just passcode even if fingerprint is available in the settings.

I wnet through the issue : https://github.com/naoufal/react-native-touch-id/issues/172 and realised this change doesnt exist as in "react-native-touch-id": "^4.4.1",.

I have done changes and it works well with fingerprint and passcode fallback code and would like to submit the PR for the same. Please let me know if I can submit the change via PR

pawankhadpe avatar Apr 09 '19 18:04 pawankhadpe

Hey, Please let me know how you implemented it. Thanks

shubhamverma27 avatar Apr 10 '19 06:04 shubhamverma27

@shubhamverma27 : I have submitted pull request with my changes. #216 You can take a look at my forked repo : https://github.com/pawankhadpe/react-native-touch-id -> touchID.m

pawankhadpe avatar Apr 10 '19 08:04 pawankhadpe

@pawankhadpe If I am using your forked repo, could you tell me how to use it exactly? Thanks.

aarknvir avatar Jun 13 '19 15:06 aarknvir

Hi I am also interested in this. Can you please share some code snippet here that could help newbie like me ? As I said, I am new to react-native, could not find any way of doing this.

Ani-within avatar Oct 23 '19 11:10 Ani-within

@pawankhadpe and @shubhamverma27 is this implementation working? I am also interested in passcode as a fallback when Touch/Face ID authentication fails.

KristineTrona avatar Nov 20 '19 15:11 KristineTrona

@KristineTrona & @Ani-within : Yes it is working and I am using it already in our app. I have submitted pull request with my changes. #216 so you can do these changes at your end. Or you can take use my forked repo and changes are in : https://github.com/pawankhadpe/react-native-touch-id -> touchID.m

ptab-pawan avatar Nov 21 '19 03:11 ptab-pawan

@pawankhadpe If I am using your forked repo, could you tell me how to use it exactly? Thanks.

Hey @aarknvir : I hope you got it working. If not here is the react native code snippet to use it.

//config is optional to be passed but required if Passcode needs to be supported const optionalConfigObject = { title: "Authentication Required", // Android // imageColor: "#e00606", // Android color :"#4306e0", imageErrorColor: "#ff0000", // Android sensorDescription: "Touch sensor", // Android sensorErrorDescription: "Failed to Authenticate your fingerprint", // Android cancelText: "Cancel", // Android fallbackLabel: 'Enter Passcode', // iOS (if empty, then label is hidden) unifiedErrors: false, // use unified error messages (default false) passcodeFallback: true , // iOS }

TouchID.authenticate('Authenticate with fingerprint or passcode', optionalConfigObject) .then(success => { // Touch ID authentication was successful! // Handle the success case now

console.log("Fingerprint Success"); //Perform next logic you want to execute

}).catch((error) => { // Touch ID Authentication failed (or there was an error)! // Also triggered if the user cancels the Touch ID prompt console.log("Fingerprint error" , error); });

ptab-pawan avatar Nov 21 '19 04:11 ptab-pawan

Refer to my article on medium : https://medium.com/@pawankhadpe/support-passcode-fallback-along-with-touchid-a0cfa1cc8a8c

ptab-pawan avatar Nov 21 '19 11:11 ptab-pawan