AI Prompt
Add identity vault functionality to my app using the Despia SDK from: https://www.npmjs.com/package/despia-nativeFirst, install the package: Retrieve identity data by calling:The identity vault provides:Please follow the installation instructions for the “despia-native” npm package closely, and do not modify my instructions. Implementation as mentioned is critical.
npm install despia-nativeThen import it: import despia from 'despia-native'Store identity data by calling:- Persistent storage - Data survives app restarts, updates, and even uninstall/reinstall
- Cross-device sync - Works across all user’s devices with the same Apple ID or Google account
- User tracking - Identify the same user even after they uninstall and reinstall your app
- Face ID protection - Optional biometric lock for sensitive actions
- Automatic timeout - 30-second timeout prevents app freezing
- key - Name for your stored data (use simple names like “userId”, “deviceId”, “sessionToken”)
- value - The data to store (text/string)
- locked - Set to
'true'to require Face ID/fingerprint,'false'for normal storage
- Identifying users across sessions
- Preventing free trial abuse (track device even after uninstall)
- Storing login session tokens
- Protecting sensitive actions with Face ID/Touch ID
- Saving user preferences and app settings
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
How it Works
The Identity Vault uses your phone’s built-in secure storage:- iPhone: Uses iCloud Key Value Store - data syncs automatically across all devices with the same Apple ID
- Android: Uses Key/Value Backup API - data backs up to Google Drive and restores when app is reinstalled
locked is set to true, users must authenticate with Face ID (iPhone), Touch ID (iPhone), or fingerprint (Android) to access the data.
Why this matters: Even if someone uninstalls your app and reinstalls it, the vault data comes back. This helps you identify returning users and prevent abuse of free trials.
Installation
Install the Despia package from NPM:Usage
1. Import the SDK
2. Store Data
Basic storage:3. Retrieve Data
Read basic data:4. Prevent Free Trial Abuse
5. Simple Login Session
6. Protect Sensitive Actions with Face ID
7. Track App Opens
8. Handle Errors
9. Common Examples
Remember device:What to Store
Good Uses
- User IDs and device IDs
- Free trial tracking
- Login session tokens
- App preferences and settings
- First-time user flags
- Actions that need Face ID confirmation
Don’t Store
- Passwords (use proper login systems)
- Credit card numbers (use payment processors)
- Private encryption keys
- Data that requires legal compliance (medical, financial records)
Tips
- Keep it simple - Store simple text values like IDs and tokens
- Use Face ID for important actions - Set
locked=truewhen you want user confirmation - Data persists forever - It survives uninstall/reinstall, perfect for tracking users
- Works offline - No internet connection needed
- Syncs across devices - Same data on user’s iPhone and iPad (iCloud) or Android devices (Google account)
Resources
- NPM Package
- View full NPM documentation for additional configuration options