Keychain
Secure storage using iOS Keychain
Keychain provides secure, encrypted storage for sensitive data like passwords and tokens. Data persists across app reinstalls and is protected by device security.
Use Keychain to:
Examples
javascript
Keychain.set("api_key", "secret123");
let key = Keychain.get("api_key");
console.log(key); // "secret123"javascript
if (Keychain.contains("token")) {
let token = Keychain.get("token");
}javascript
Keychain.remove("old_password");Methods
contains
Check if a key exists in keychain
typescript
static contains(key): booleankey- Key to check
Returns: true if key exists
Example:
javascript
Keychain.contains("api_key")set
Store a value in keychain
Overwrites existing value if key exists.
typescript
static set(key, value): voidkey- Key to store undervalue- String value to store
Example:
javascript
Keychain.set("key", "value")get
Retrieve a value from keychain
Throws error if key not found.
typescript
static get(key): string | nullkey- Key to retrieve
Returns: Stored value
Example:
javascript
let value = Keychain.get("key")remove
Remove a value from keychain
typescript
static remove(key): voidkey- Key to remove
Example:
javascript
Keychain.remove("key")