Digital Signature — React Native
Digital Signature has been around for some time now. At the time of this write-up, it is practically impossible for you to be a mobile developer without having to create and use Digital Signature for taking user confirmation.
A digital signature is exactly what it sounds like a modern alternative to signing documents with paper and pen. It uses an advanced mathematical technique to check the authenticity and integrity of digital messages and documents.
Installation
You have to install the react-native-signature-capture
package. You’ll need to run the expo install
command as well to install its dependencies if you’re using Expo!
App.js
The above code represents the actual code for Signature Pad and Save & Reset.
Save and Reset Sign
In our App.js, we are going to create the function App and as usual export default App;
A few notes on the above:
- First, we are creating a reference variable to keep track of our signature ref using createRef() function.
- We are creating two methods for saving signatures and resetting signatures.
- The
saveSign()
usessign.current.saveImage()
function to save images locally on the runtime. - The
resetSign()
usessign.current.resetImage()
function to reset image locally on the runtime.
Event Capture
The code is simply to generate a response __onSaveEvent
to capture gesture movement, and __onDragEvent
to log the drag event.
Code Reference
Github Link — https://github.com/LuffyAnshul/RNDigitalSignature