react-native-touch-id
react-native-touch-id copied to clipboard
[iOS] : Support Fallback along with Fingerprint.
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
Hey, Please let me know how you implemented it. Thanks
@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 If I am using your forked repo, could you tell me how to use it exactly? Thanks.
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.
@pawankhadpe and @shubhamverma27 is this implementation working? I am also interested in passcode as a fallback when Touch/Face ID authentication fails.
@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
@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); });
Refer to my article on medium : https://medium.com/@pawankhadpe/support-passcode-fallback-along-with-touchid-a0cfa1cc8a8c