Skip to content

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): boolean
  • key - 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): void
  • key - Key to store under
  • value - 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 | null
  • key - Key to retrieve

Returns: Stored value

Example:

javascript
let value = Keychain.get("key")

remove

Remove a value from keychain

typescript
static remove(key): void
  • key - Key to remove

Example:

javascript
Keychain.remove("key")